Skip to content

Instantly share code, notes, and snippets.

@getify
Last active July 10, 2018 12:42
Show Gist options
  • Save getify/5959149 to your computer and use it in GitHub Desktop.
Save getify/5959149 to your computer and use it in GitHub Desktop.
asynquence: sequences & gates at a glance. https://github.com/getify/asynquence
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!");
});
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()
.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!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment