A.10. Asynchronous processing
To arrange asynchronous processing in ES5, you had to use callbacks—functions that are given as arguments to another function for invocation. Callbacks can be called synchronously or asynchronously.
For example, you can pass a callback to an array’s forEach() method for synchronous invocation. In making AJAX requests to a server, you can pass a callback function to be invoked asynchronously when the result arrives from the server.
A.10.1. A callback hell
Let’s consider an example of getting data about some ordered products from a server. It starts with an asynchronous call to the server to get the information about the customers, and then for each customer you’ll need to make another call to get the orders. For ...
Get TypeScript Quickly now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.