Created
May 25, 2015 12:41
-
-
Save id0Sch/a69a18e39da2c32cf4a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Created by idoschachter on 5/25/15. | |
*/ | |
var Promise = require('bluebird'); | |
function promiseA(){ | |
return new Promise.resolve('a'); | |
} | |
function promiseB(resultA){ | |
return new Promise.resolve(resultA+'b'); | |
} | |
function getExample() { | |
var a = promiseA(); | |
var b = a.then(promiseB); | |
return Promise.all([a, b]).spread(function(resultA, resultB) { | |
console.log(resultA, resultB); | |
}); | |
} | |
getExample(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment