Created
August 20, 2015 23:53
-
-
Save gartenfeld/1c11c0dc07f016ebb19d to your computer and use it in GitHub Desktop.
Promises with Bluebird.
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
var Promise = require('bluebird'); | |
var async = function (input) { | |
return new Promise(function (resolve, reject) { | |
var data = input + ' Whatever.'; | |
// call the async process here | |
setTimeout(function(){ | |
// send the result when it arrives | |
resolve(data); | |
}, 100); | |
}); | |
}; | |
async("Hello.") | |
.then(function (data) { | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment