Created
March 12, 2015 05:39
-
-
Save mwheeler/fc445c13f077bf208852 to your computer and use it in GitHub Desktop.
Promise.all example
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
var Promise = require('bluebird'); | |
Promise.longStackTraces(); | |
var A = new Promise(function(pass, fail) | |
{ | |
console.log("A started"); | |
setTimeout(function() | |
{ | |
console.log("A finished"); | |
pass(); | |
}, 1000); | |
}); | |
var B = new Promise(function(pass, fail) | |
{ | |
console.log("B started"); | |
setTimeout(function() | |
{ | |
console.log("B finished"); | |
pass(); | |
}, 2000); | |
}); | |
var C = console.log.bind(undefined, "YAY!"); | |
Promise.all([A, B]).then(C, console.log.bind(undefined)).finally(console.log.bind(undefined, "\nTest Complete!")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment