3 ms·
So.... we introduced Promises so that we could introduce fetch() that returns a Promise, only to discover that it meant we couldn't get all the other useful beh
by couchand 10y ago
So.... we introduced Promises so that we could introduce fetch() that returns a Promise, only to discover that it meant we couldn't get all the other useful behavior of XMLHttpRequest. So while a proposal to add cancelable Promises would fix the inability to abort, we'd still need yet more additions to completely get back to functionality we had previously.
- idbehold 10y agoThat wasn't the reason promises were introduced. An XMLHttpRequest can be synchronous which is Bad™ and that is something explicitly not allowed by the Promise/A+ spec which means it will never be something that fetch() could do. The advantage of promises is that they can be `await`ed in the context of an `async` function which takes a lot of the cognitive load off of the developer.
- Klathmon 10y agoFurthermore the `await` syntax is one of the reasons why cancelable promises is contentious. There's no easy way to "cancel" an awaited promise without basically resorting to the .then() syntax.