Last active
July 10, 2018 12:42
-
-
Save getify/5959149 to your computer and use it in GitHub Desktop.
asynquence: sequences & gates at a glance. https://github.com/getify/asynquence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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