WICG / observable

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

Make Observable disposable #150

Open jasnell opened 3 months ago

jasnell commented 3 months ago

It would be useful for the Observable class to support the upcoming Symbol.dispose or Symbol.asyncDispose mechanism (TC39 Explicit Resource Management proposal) such that when the Observable is disposed while still active, any outstanding subscriptions and closed and outstanding promises are rejected.

using obs1 = eventTarget.on('foo');
using obs2 = Observable.from(asyncIterable);

This is particularly helpful in cases where a block of code may wish to only temporarily attach itself to a particular event source (like an EventTarget that long outlives the Observable)