Re: [whatwg/dom] Consider adding AbortController.prototype.follow(signal) (#920)

A few points:

1. I agree this would be a good thing to add, if only because so many users are asking for it. This holds regardless of my next two points.

1. The "follow" operation has always seemed unintuitive to me, compared with a "race" or "create linked token source" style API ([described here in the context of the defunct cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises/blob/0e769fda8e16bff0feffe964fddc43dcd86668ba/Cancel%20Tokens.md#combining-cancel-tokens)). But, I don't trust my inutition here. Would someone with more experience be able to discuss the differences between these, and argue for one or the other?

1. Even if we add this high-level combinator, it'd be ideal if it could be expressed in userland code. There are a few potential missing primitives here, and I believe any one of them would suffice:
   - Weak event listeners. @syg and I discussed this in some private chat some months ago. You can get close to emulating these today with `WeakRef`, but you'll leak a bit of memory for the wrapper thunk, which looks like `e => weakRef.get().?(e)`.
   
   - Some way of clearing all event listeners for the signal's `"abort"` event after the controller's `abort()` is called. E.g. https://github.com/whatwg/dom/issues/412 would allow this. If we exposed this then I'd suggest `abort()` auto-clears all listeners. (Which would be a backward-incompatible change, but hopefully a safe one.)
   
   - Probably some other ideas.

1. I don't fully understand the relationship between the issues discussed here, and how fetch() and other platform features ignore the event listener mechanisms in favor of their own internal "abort steps". But, in the past I've advocated against this magic; see https://github.com/whatwg/dom/issues/493 and the somewhat-related https://github.com/whatwg/dom/issues/878 .

-- 
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/920#issuecomment-726961899

Received on Friday, 13 November 2020 18:45:22 UTC