4 ms·
As already mentioned, they're a lot better than callbacks (well, for certain cases. There are still places where callbacks are better). The problem is that thi
by shados 9y ago
As already mentioned, they're a lot better than callbacks (well, for certain cases. There are still places where callbacks are better).
The problem is that this is a field that has been heavily studied, and there are great solutions to this problem that also solve countless other problems, and interop well with each other. The way promises work, they solve that ONE problem but throw away the rest.
If you have the choice between 2 mostly equivalent solutions to solve a problem, but one of the solutions also solve 10 other problems with essentially no drawback, why would you choose the former?
This is probably already linked in this thread somewhere and is also probably was prompted someone to post this old issue to Hacker news, but this is a good explanation of the problem:
https://staltz.com/promises-are-not-neutral-enough.html https://staltz.com/promises-are-not-neutral-enough.html
- todd_wanna_code 9y ago> There are still places where callbacks are better) Like? I am genuinely interested in knowing the drawbacks of promises and places where a callback like structure is more favourable. By the way, I am not contradicting you, just trying to learn.
- shados 9y agofoo.map(x => x * 2); Not sure I'd want to use a promise there :)
- imtringued 9y agoA promise can only be activated once. You still have to use callbacks for buttons and other things that can be activated more than once.