5 ms·
I've had this same cancellation conversation many times with JS programmers. I think it's fair to say there's a need for standardization. Evidence for this need
by coke12 3y ago
I've had this same cancellation conversation many times with JS programmers. I think it's fair to say there's a need for standardization. Evidence for this need is network request management is really poor in pretty much all JS apps.
- capableweb 3y agoSpecifically the case of request management, it's already implemented and available in all browsers practically. It's like four lines of code you have to add/change, to be able to cancel a request. https://developer.mozilla.org/en-US/docs/Web/API/AbortController https://developer.mozilla.org/en-US/docs/Web/API/AbortContro... Regarding other cases, there are already ways of handling those. I don't think just because many ask about something, doesn't mean it's not currently working.
- coke12 3y agoThere are a lot of issues with the ergonomics of AbortController. It's very low level.
- capableweb 3y agoDid you actually look at the link I sent you? It's absolutely not low level. If you know how to use window.fetch, you know how to use AbortController already. controller = new AbortController(); const signal = controller.signal; fetch("http://example.com", { signal: signal }) // abort request controller.abort(); It basically couldn't be simpler? What sort of API would you like to be able to cancel requests?
- coke12 3y agoThat's a toy example! In reality in a complex app you'd usually be aborting far from where the fetch is created, and you'd have large promise chains where the semantics of cancellation are non-obvious and even unintuitive.