Function takeUntilCompleteOrError

  • Returns an operator that completes the source observable when the notifier observable either completes or errors. Unlike takeUntil, which reacts only to the notifier’s next emissions, this operator also stops the source when the notifier finishes or fails.

    Returns

    A MonoTypeOperatorFunction that completes the source when the notifier completes or errors.

    Example

    const notifier$ = ajax.getJSON('/config'); // May error or complete

    source$.pipe(
    takeUntilCompleteOrError(notifier$)
    ).subscribe({
    next: console.log,
    complete: () => console.log('Stopped due to notifier completing'),
    error: console.error
    });

    // The subscription to source$ ends as soon as:
    // 1) notifier$ completes, or
    // 2) notifier$ errors.

    // NOTE: Any values emitted by notifier$ are ignored.

    Type Parameters

    • T

      The value type of the source observable.

    Parameters

    • notifier$: Observable<any>

      Observable whose termination (complete or error) will stop the source.

    Returns MonoTypeOperatorFunction<T>

Generated using TypeDoc