O'Reilly logo

Async JavaScript by Trevor Burnham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Organizing Tasks with Async.js

Async.js’s collection methods solve the problem of applying a single async function to a set of data. But what if, instead of a set of data, we have a set of functions? In this section, we’ll explore some of the powerful tools that Async.js has for dispatching async functions and collecting their results.

Running an Async Series

Suppose we have an array of async functions that we want to run in order. Without the use of a utility function, we might have to write something like this:

 
funcs[0](​function​() {
 
funcs[1](​function​() {
 
funcs[2](onComplete);
 
})
 
});

Fortunately, we have async.series and async.waterfall. Each takes an array of functions (the task list) and runs them sequentially, passing each ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required