Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Created March 4, 2014 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickJS/9340949 to your computer and use it in GitHub Desktop.
Save PatrickJS/9340949 to your computer and use it in GitHub Desktop.
var Promise = require('bluebird');
var facebookAsync = function() {
var dfd = Promise.defer();
FB.login(function(err, user) {
if (err) {
dfd.reject(err);
} else {
dfd.resolve(user);
}
});
return dfd.promise;
};
facebookAsync.then(function(user) {
console.log('User', user);
});
function FB(callback) {
// this.init();
}
FB.prototype.login = function(callback) {
var user = {
name: 'PatrickJS'
};
setTimeout(function() {
callback(null, user);
}, 3000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment