4 ms·
I don't agree. Promises are a solution to the asynchronous callback world, not a dream spec someone came up with. 1. Eager, not lazy: Why is lazy better? Somet
by fiatjaf 9y ago
I don't agree. Promises are a solution to the asynchronous callback world, not a dream spec someone came up with.
1. Eager, not lazy: Why is lazy better? Sometimes I want eager, I use promises. Sometimes I want lazy, I use a promise getter. Done. What if it was the other case, how would I turn a lazy promise into an eager one without messy code?
2. No cancellation. Events that permit cancellation are rare. Situations in which you would want to cancel something are rare. If you face these, use a promise library that does permit cancellation. Bluebird does it.
3. Never synchronous. If you want synchronous, just don't use a Promise, use a function that takes another function. I don't get the point about "callbacks to sync". Callbacks are asynchronous. "Synchronous callbacks" may have this name, but they're not actually callbacks, they're functions. A function can take another function as a parameter, that doesn't automatically make it into a "callback".