Skip to content

Instantly share code, notes, and snippets.

@lifeinafolder
Created January 15, 2012 20:07
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 lifeinafolder/1617020 to your computer and use it in GitHub Desktop.
Save lifeinafolder/1617020 to your computer and use it in GitHub Desktop.
Promise Example
asyncCall(data,function(response){
// You have response from your asynchronous call here.
}, function(err){
// if the async call fails, the error callback is invoked
});
// And now with Promises pattern, you would write it like this:
var promise = asyncCall(data);
promise.done(function(response){
// You have response from your asynchronous call here.
}).fail(function(err){
// if the async call fails, you have the error response here.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment