If you noticed carefully, with both callbacks and promises, there is an overhead involved. With callbacks, the overhead is in the form of writing and maintaining callback functions that need to be passed in each time we call an asynchronous function. Within the callback function, we need to handle both the success and error case.
With promises, one good thing is, we no longer need to pass around callbacks, but similar to callbacks, there is an overhead in terms of handling the resolution in then
and the error in catch
.
Furthermore, one of the worst pain points is exposed when dealing with chained callbacks/promises. Calling subsequent asynchronous functions after the previous asynchronous function calls have completed leads to very messy looking code.
Wouldn't it be nice to be able to call asynchronous functions in a linear fashion irrespective of the calling order? Wouldn't it be nice to write asynchronous code just like you would write synchronous code, without worrying about...