Possible Duplicate:
What are the differences between Deferred, Promise and Future in Javascript?
Can someone point out what are the differences are between callbacks and promises? When should one use promise etc?
Also links on how to create and use promises will be appreciated.
Promises provide a more succinct and clear way of representing sequential asynchronous operations in javascript. They are effectively a different syntax for achieving the same effect as callbacks. The advantage is increased readability. Something like this
aAsync() .then(bAsync) .then(cAsync) .done(finish);
is much more readable then the equivalent of passing each of those individual functions as callbacks, like
Async(function(){ return bAsync(function(){ return cAsync(function(){ finish() }) }) });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With