- From: James Browning <notifications@github.com>
- Date: Sun, 19 Dec 2021 22:53:07 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1039/997644983@github.com>
> This is one of very few "manual resource management" operations in the web platform, and the first that is not tied to a large chunk of binary data. (Others I can think of are Blob/File, URL.revokeObjectURL(), and ImageBitmap.) Is this a reasonable precedent to set? Do we want to encourage a coding style that sprinkles close() calls throughout, like a C-style free()? > * This would be the first bit of `AbortSignal` that is not implementable in "userland", i.e. it requires the ability to remove all listeners. Is that OK? Or should we perhaps expose the primitive in [[Proposal] Add EventTarget.getEventListeners() #412](https://github.com/whatwg/dom/issues/412) first? > * Is it OK that you can add `abort` listeners after closing? They won't be triggered by `abort()` (since `abort()` is a no-op after closing in the proposal), but they still exist. I opened another issue a while ago to allow attaching [trusted-event only listeners](https://github.com/whatwg/dom/issues/1016) which would essentially allow for the lifetime of listeners to be tied to the controller, NOT to the event-target itself. i.e. We could do: ```js let controller = new AbortController(); controller.signal.addEventListener( "abort", () => { console.log("Aborted!"); }, { trustedOnly: true }, ); ``` and if the controller performs `.abort()` then it can immediately collect all listeners with `trustedOnly: true` as the only way to create a trusted event is via the `controller`. Similarly if `controller` is collected then all such `trustedOnly: true` listeners can be collected as well. Late listeners similarly could just be immediately discarded as they will never be callable if the controller has been collected or already aborted. The opt-in of the flag is the main thing I don't like about the idea, but it could be possible for certain events to have `trustedOnly: true` be default. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1039#issuecomment-997644983 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1039/997644983@github.com>
Received on Monday, 20 December 2021 06:53:20 UTC