abort-controller-x-rxjs
Version:
Abortable helpers for RxJS
13 lines • 518 B
JavaScript
import { first } from 'rxjs/operators';
import { lastValueFrom } from './lastValueFrom';
/**
* Like original `firstValueFrom` from RxJS, but accepts `AbortSignal`. When
* that signal is aborted, unsubscribes from the observable and throws
* `AbortError`.
*/
export function firstValueFrom(signal, source, config) {
return typeof config === 'object'
? lastValueFrom(signal, source.pipe(first()), config)
: lastValueFrom(signal, source.pipe(first()));
}
//# sourceMappingURL=firstValueFrom.js.map