rxjs icon indicating copy to clipboard operation
rxjs copied to clipboard

Feature: AbortSignal support first value from last value from

Open benlesh opened this issue 3 years ago • 4 comments

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

benlesh avatar Nov 15 '21 22:11 benlesh

Neat.

benjamingr avatar Nov 21 '21 13:11 benjamingr

Core Team: Still uncertain about this direction, maybe we change the name of the config property to unstable_signal and let folks try it?

benlesh avatar Jan 12 '22 21:01 benlesh

Core Team meeting:

  1. @benlesh says he's worried about diving into AbortSignal if 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.
  2. Actionable: Reach out @benjamingr et al, about what needs we would really have to move the whole library this way.
  3. Alternative idea: have a signal_UNSAFE configuration to try out the waters.

benlesh avatar Mar 23 '22 20:03 benlesh

@benlesh @benjamingr Any hope of progress on this one?

ronag avatar May 23 '22 06:05 ronag

Anything we can do to move this forward?

deadbeef84 avatar Nov 01 '22 20:11 deadbeef84

In the meantime you can use this third-party implementation: https://github.com/deeplay-io/abort-controller-x-rxjs

aikoven avatar Nov 02 '22 05:11 aikoven

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.

benlesh avatar Jan 20 '23 03:01 benlesh