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

> "every await should honor the signal” model is important

Agreed. This is not only true from an ergonomic perspective (we don't want people to forget to race the signal and thus fall into the pit of failure) but also in the learning/documentation perspective (we should want to make it *easy* and *obvious* to do the right thing and hard to do the wrong thing).

CAF took that philosophy to heart in its design, and that was the reason that it went with generators instead of async functions. In this way, CAF treats `yield` like a customizable `await`, and thus it forces every `yield` to automatically respect (race) the current in-scope cancelation signal without the userland code having to opt-in to that. For flexibility reasons, CAF *also* exposes the underlying `pr` promise *on the signal* so that userland can choose to do more sophisticated/customized workflow (like combining multiple levels of `Promise.race(..)` and `Promise.all(..)`, etc, if they want to. But ultimately, CAF ensures that every `yield` honors the signal, because `yield` is *programmable* and `await` (at the moment) isn't.

-- 
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-846149682

Received on Friday, 21 May 2021 18:22:00 UTC