WICG / observable

Observable API proposal
https://wicg.github.io/observable/
Other
543 stars 12 forks source link

Why not add the .addTeardown method to AbortSignal proper? #146

Closed Jamesernator closed 1 month ago

Jamesernator commented 1 month ago

So on Subscriber we have .addTeardown which adds a convenient way to ensure teardown happens even if the subscriber is already closed. It's not clear to me why though this isn't just added to AbortSignal proper as it just calls the cleanup when subscriber.signal is aborted anyway.

The .addTeardown method would be equally useful in Promise (or callback) usage in basically the same pattern as in Observable so I don't really see a reason to restrict this method to being part of just Observable.

domfarolino commented 1 month ago

It seems like some version of it could have a place on AbortSignal. I recommend filing an issue on the DOM Standard. This is out-of-scope for this repository.