Skip to content

Instantly share code, notes, and snippets.

@gartenfeld
Created August 20, 2015 23:53
Show Gist options
  • Save gartenfeld/1c11c0dc07f016ebb19d to your computer and use it in GitHub Desktop.
Save gartenfeld/1c11c0dc07f016ebb19d to your computer and use it in GitHub Desktop.
Promises with Bluebird.
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