Well most of my day involves writing Javascript for node.js, so there'll be a lot of situations where an operation requires multiple asynchronous database calls, or to verify something in redis before continuing, and things down the line will depend on having access to the results of previous async operations.
If this were to be done using callbacks it would involve a lot of unavoidable nesting.
I'm not saying that callbacks are best in every situation, but I am saying that promises also aren't best in every situation.
I disagree, I find that promises are a very useful pattern for most situations. With Javascript being a single-threaded, async operations are a fundamental part of writing good Javascript, because especially with Node you really can't afford to have synchronous code blocking the stack, because it'll block the stack for literally every user connected to that specific instance of your application.
A lot of our code at work is architected around promises as a standard interface. If we use a library or module that uses callbacks, we'll use es6-promisify to wrap that in a promise so that its easier to work with.
The only instance I can think of where plain callbacks make sense are in event handlers, such as in node.js streams or event listeners in the browser.
0
u/[deleted] Jul 11 '16
[deleted]