Skip to content

Instantly share code, notes, and snippets.

@id0Sch
Created May 25, 2015 12:41
Show Gist options
  • Save id0Sch/a69a18e39da2c32cf4a5 to your computer and use it in GitHub Desktop.
Save id0Sch/a69a18e39da2c32cf4a5 to your computer and use it in GitHub Desktop.
/**
* 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