WICG / observable

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

Spec the `map()` operator #110

Closed domfarolino closed 4 months ago

domfarolino commented 4 months ago

The original version of this PR made it so if the |mapper| callback throws an error, it is "reported" to the global.

However, I've since fixed this to invoke the error() method on the relevant "Subscriber". This will either (a) let the subscriber handle it, or (b) if there are no error steps, report the exception (due to the default error steps). That's the right behavior.

Additionally, in this error-case we also need to unsubscribe from the |sourceObservable|, which is accomplished by having the nexts steps abort an AbortController that |signal| is derived from, where |signal| is the AbortSignal passed into the outer Observable subscription.

Tests are in https://github.com/web-platform-tests/wpt/pull/42996/files#diff-8bcbcee0a9e290fe595f3a4d260648dc3900c67bab5925715011728b1df24d7f (written by @benlesh) but I will port them over to the Chromium CL, add more over there, and land them with the implementation. They'll get upstreamed to the external WPT repository with appropriate Git commit attribution.


Preview | Diff