Re: [whatwg/dom] Expose an `aborted` promise on AbortSignal? (#946)

From https://github.com/whatwg/dom/issues/981#issuecomment-845847876:


> @jakearchibald fwiw I think the doAbortable model shown in that thread is, at best, moving an existing problem around. The need is to “decorate await”, not to “decorate async”, and it would probably not be great to encourage the latter. That is, usually _each_ interleaving point / control yield would want to “race the signal”. This is always going to be awkward, but the awkwardness can be minimized. I mentioned the `race` util we use in particular for this reason — it’s the “building block” of all the signal patterns we’ve found/needed to date.
> 
> I would love to see `signal.race(Promise<any> p)` become native. Once you’re always racing the signal, you get to use catch/finally just like in any other sync or async function. I believe some form of `race`+`isAbortError` would be the minimal API needed to fix the “syntax gap”.

Would add that `race` itself implies one smaller unit that may be deserving of exposure in its own right, “toPromise(signal)”. (Apologies if these ideas duplicate things which were previously discussed here or elsewhere since I haven’t read everything all relevant comments yet.)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/946#issuecomment-845854660

Received on Friday, 21 May 2021 10:33:02 UTC