rxjs
rxjs copied to clipboard
Feature: AbortSignal support first value from last value from
feat(lastValueFrom): Adds support for cancellation with AbortSignal.
Similar to the update to firstValueFrom. This adds a configuration option to unsubscribe from the underlying subscription with an AbortSignal. If aborted with a signal, the returned promise will reject with an AbortError.
resolves #6442
feat(firstValueFrom): now supports AbortSignal cancellation
Adds a feature to the firstValueFrom config to support passing an AbortSignal that can be used to unsubscribe from the underlying subscription. This will result in the returned promise rejecting with an AbortError, which is an error type belonging to the library at this point. This is because there is no consistent error type to throw across all supported runtimes that the user could check for.
related #6442
Neat.
Core Team: Still uncertain about this direction, maybe we change the name of the config property to unstable_signal and let folks try it?
Core Team meeting:
- @benlesh says he's worried about diving into
AbortSignalif it is never going to meet our ergonomics needs. But would still really, really like it if a native cancellation type like this worked out. - Actionable: Reach out @benjamingr et al, about what needs we would really have to move the whole library this way.
- Alternative idea: have a
signal_UNSAFEconfiguration to try out the waters.
@benlesh @benjamingr Any hope of progress on this one?
Anything we can do to move this forward?
In the meantime you can use this third-party implementation: https://github.com/deeplay-io/abort-controller-x-rxjs
After using AbortSignal for a large project that was dealing with high-speed emissions, the performance of AbortSignal, in particular adding and removing event listeners for abort events, was so incredibly poor that I'm unwilling to introduce any flavor of it in RxJS.
We were waiting and waiting for this and thinking maybe we'd break ground on it in 8.x. And now I can't say that I think it's a good idea.
Use takeUntil(fromEvent(signal, 'abort')) in the meantime.