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

> You can forget to remove the listener correctly when the resource is finished and leak memory.

Just to clarify, the resource only stays in memory until `signal` is GC'd, at which point [it's all collected](https://jakearchibald.com/2020/events-and-gc/).

> One alternative suggested was to have a utility method that helps with this, the above code bemes:
> 
> ```js
> // the second parameter is so the listener is removed when the resource gets GCd. 
> aborted(signal, resource).then(() => resource.cleanup());
> ```

What mechanism is it using for that? Weakrefs?

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

Received on Thursday, 4 February 2021 14:58:05 UTC