public
Last active

asynquence: sequences & gates at a glance. https://github.com/getify/asynquence

  • Download Gist
only-gate.js
JavaScript
1 2 3 4 5 6 7 8 9
ASQ()
.gate(
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!");
});
only-steps.js
JavaScript
1 2 3 4 5 6 7
ASQ()
.then(function(done){ setTimeout(done,100); })
.then(function(done){ setTimeout(done,200); })
.then(function(done){ setTimeout(done,300); })
.then(function(){
alert("All tasks are complete, and that took ~600ms!");
});
steps-and-gates.js
JavaScript
1 2 3 4 5 6 7 8 9
ASQ()
.then(function(done){ setTimeout(done,100); })
.gate(
function(done){ setTimeout(done,200); },
function(done){ setTimeout(done,300); }
)
.then(function(){
alert("All tasks are complete, and that took ~400ms!");
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.