5 ms·
Not sure if it had been mentioned already, but I think we could benefit from cancellable Promises. Many of the modules and libraries currently support Promises
by TravelTechGuy 8y ago
Not sure if it had been mentioned already, but I think we could benefit from cancellable Promises.
Many of the modules and libraries currently support Promises, and `async/await`, but try to find a way to cancel a long-running Promise. Some libraries have resorted to using their own mechanisms, and some (e.g. `axios`) resorted to using a withdrawn TC39 proposal.
I'd like a standard, easy way to cancel a Promise. I know it's not simple, and Promises can wrap around other Promises, etc. but if I'm e.g. uploading a large file to a server, there should be an easy way to provide my users with a "cancel" button that works.
- tjallingt 8y agotheres the AbortController [1] that can be used on a few new promise based APIs such as the Fetch API [2] [1] https://developer.mozilla.org/en-US/docs/Web/API/AbortController https://developer.mozilla.org/en-US/docs/Web/API/AbortContro... [2] https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
- TravelTechGuy 8y agoBut there's no easy way to inject this AbortControl into existing libraries, or use it easily with async/await. I'm looking for an easier standard.