asynquence: sequences & gates at a glance. https://github.com/getify/asynquence
ASQ()
.then(function(done){ setTimeout(done,100); })
.all( // or .gate(..)
// these 2 run "in parallel"
function(done){ setTimeout(done,200); },
function(done){ setTimeout(done,300); }
)
.then(function(){
alert("All tasks are complete, and that took ~400ms!");
});
ASQ()
.then(
// these 3 run "in succession"
function(done){ setTimeout(done,100); },
function(done){ setTimeout(done,200); },
function(done){ setTimeout(done,300); }
)
.then(function(){
alert("All tasks are complete, and that took ~600ms!");
});
ASQ()
.all( // or .gate(..)
// these 3 run "in parallel"
function(done){ setTimeout(done,100); },
function(done){ setTimeout(done,200); },
function(done){ setTimeout(done,300); }
)
.then(function(){
alert("All tasks are complete, and that only took ~300ms, not 600ms!");
});