Created
January 15, 2012 20:07
-
-
Save lifeinafolder/1617020 to your computer and use it in GitHub Desktop.
Promise Example
This file contains 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
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