Skip to content

Instantly share code, notes, and snippets.

@joelcox
Created February 19, 2015 09:33
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 joelcox/873d296461c09b171b26 to your computer and use it in GitHub Desktop.
Save joelcox/873d296461c09b171b26 to your computer and use it in GitHub Desktop.
Dealing with basic promises
var promise = new Ember.RSVP.Promise(function(resolve, reject) {
console.log('Promise is pending');
setTimeout(function() {
if (Math.random() < 0.7) {
resolve({'status': 'ok'});
}
reject('Whoops, something went wrong');
}, 1000);
});
promise.then(function(response) {
console.log(response);
}, function(error) {
console.error(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment