Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Promises
/* Without Promises */
asynchronousFunctionOne(function(value){
somethingSync(value);
asynchronousFunctionTwo(function(){
somethingElseSync();
asynchronousFunctionThree(function(){
console.log("Done!");
});
});
});
/* With Promises */
Promise.try(function(){
return asynchronousFunctionOne();
}).then(function(value){
somethingSync(value);
return asynchronousFunctionTwo();
}).then(function(){
somethingElseSync();
return asynchronousFunctionThree();
}).then(function(){
console.log("Done!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment