PATH:
usr
/
local
/
lib
/
node_modules
/
ghost-cli
/
node_modules
/
rxjs
/
src
/
internal
/
operators
import { Operator } from '../Operator'; import { Observable } from '../Observable'; import { Subscriber } from '../Subscriber'; import { Subscription } from '../Subscription'; import { OuterSubscriber } from '../OuterSubscriber'; import { subscribeToResult } from '../util/subscribeToResult'; import { ObservableInput, OperatorFunction, TeardownLogic } from '../types'; export function exhaust<T>(): OperatorFunction<ObservableInput<T>, T>; export function exhaust<R>(): OperatorFunction<any, R>; /** * Converts a higher-order Observable into a first-order Observable by dropping * inner Observables while the previous inner Observable has not yet completed. * * <span class="informal">Flattens an Observable-of-Observables by dropping the * next inner Observables while the current inner is still executing.</span> * *  * * `exhaust` subscribes to an Observable that emits Observables, also known as a * higher-order Observable. Each time it observes one of these emitted inner * Observables, the output Observable begins emitting the items emitted by that * inner Observable. So far, it behaves like {@link mergeAll}. However, * `exhaust` ignores every new inner Observable if the previous Observable has * not yet completed. Once that one completes, it will accept and flatten the * next inner Observable and repeat this process. * * ## Example * Run a finite timer for each click, only if there is no currently active timer * ```ts * import { fromEvent, interval } from 'rxjs'; * import { exhaust, map, take } from 'rxjs/operators'; * * const clicks = fromEvent(document, 'click'); * const higherOrder = clicks.pipe( * map((ev) => interval(1000).pipe(take(5))), * ); * const result = higherOrder.pipe(exhaust()); * result.subscribe(x => console.log(x)); * ``` * * @see {@link combineAll} * @see {@link concatAll} * @see {@link switchAll} * @see {@link switchMap} * @see {@link mergeAll} * @see {@link exhaustMap} * @see {@link zipAll} * * @return {Observable} An Observable that takes a source of Observables and propagates the first observable * exclusively until it completes before subscribing to the next. * @method exhaust * @owner Observable */ export function exhaust<T>(): OperatorFunction<any, T> { return (source: Observable<T>) => source.lift(new SwitchFirstOperator<T>()); } class SwitchFirstOperator<T> implements Operator<T, T> { call(subscriber: Subscriber<T>, source: any): TeardownLogic { return source.subscribe(new SwitchFirstSubscriber(subscriber)); } } /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ class SwitchFirstSubscriber<T> extends OuterSubscriber<T, T> { private hasCompleted: boolean = false; private hasSubscription: boolean = false; constructor(destination: Subscriber<T>) { super(destination); } protected _next(value: T): void { if (!this.hasSubscription) { this.hasSubscription = true; this.add(subscribeToResult(this, value)); } } protected _complete(): void { this.hasCompleted = true; if (!this.hasSubscription) { this.destination.complete(); } } notifyComplete(innerSub: Subscription): void { this.remove(innerSub); this.hasSubscription = false; if (this.hasCompleted) { this.destination.complete(); } } }
[-] toArray.ts
[edit]
[-] window.ts
[edit]
[-] retry.ts
[edit]
[-] mergeAll.ts
[edit]
[-] windowWhen.ts
[edit]
[-] every.ts
[edit]
[-] timeout.ts
[edit]
[-] debounceTime.ts
[edit]
[-] index.ts
[edit]
[-] takeWhile.ts
[edit]
[-] audit.ts
[edit]
[-] reduce.ts
[edit]
[-] mapTo.ts
[edit]
[-] count.ts
[edit]
[-] debounce.ts
[edit]
[-] throwIfEmpty.ts
[edit]
[-] auditTime.ts
[edit]
[-] scan.ts
[edit]
[-] switchAll.ts
[edit]
[-] map.ts
[edit]
[-] bufferCount.ts
[edit]
[-] mergeScan.ts
[edit]
[-] publish.ts
[edit]
[-] min.ts
[edit]
[+]
..
[-] publishReplay.ts
[edit]
[-] bufferTime.ts
[edit]
[-] share.ts
[edit]
[-] repeat.ts
[edit]
[-] distinct.ts
[edit]
[-] concatMapTo.ts
[edit]
[-] buffer.ts
[edit]
[-] concatMap.ts
[edit]
[-] max.ts
[edit]
[-] partition.ts
[edit]
[-] observeOn.ts
[edit]
[-] bufferWhen.ts
[edit]
[-] dematerialize.ts
[edit]
[-] throttle.ts
[edit]
[-] groupBy.ts
[edit]
[-] withLatestFrom.ts
[edit]
[-] exhaust.ts
[edit]
[-] exhaustMap.ts
[edit]
[-] retryWhen.ts
[edit]
[-] zipAll.ts
[edit]
[-] find.ts
[edit]
[-] mergeMap.ts
[edit]
[-] single.ts
[edit]
[-] last.ts
[edit]
[-] combineLatest.ts
[edit]
[-] publishLast.ts
[edit]
[-] pluck.ts
[edit]
[-] pairwise.ts
[edit]
[-] distinctUntilChanged.ts
[edit]
[-] timeInterval.ts
[edit]
[-] shareReplay.ts
[edit]
[-] skipUntil.ts
[edit]
[-] findIndex.ts
[edit]
[-] windowToggle.ts
[edit]
[-] startWith.ts
[edit]
[-] timeoutWith.ts
[edit]
[-] concat.ts
[edit]
[-] materialize.ts
[edit]
[-] timestamp.ts
[edit]
[-] onErrorResumeNext.ts
[edit]
[-] subscribeOn.ts
[edit]
[-] takeUntil.ts
[edit]
[-] skipLast.ts
[edit]
[-] throttleTime.ts
[edit]
[-] mergeMapTo.ts
[edit]
[-] multicast.ts
[edit]
[-] merge.ts
[edit]
[-] takeLast.ts
[edit]
[-] delayWhen.ts
[edit]
[-] sampleTime.ts
[edit]
[-] tap.ts
[edit]
[-] take.ts
[edit]
[-] sample.ts
[edit]
[-] filter.ts
[edit]
[-] skip.ts
[edit]
[-] expand.ts
[edit]
[-] publishBehavior.ts
[edit]
[-] sequenceEqual.ts
[edit]
[-] ignoreElements.ts
[edit]
[-] catchError.ts
[edit]
[-] endWith.ts
[edit]
[-] refCount.ts
[edit]
[-] windowCount.ts
[edit]
[-] defaultIfEmpty.ts
[edit]
[-] windowTime.ts
[edit]
[-] switchMapTo.ts
[edit]
[-] switchMap.ts
[edit]
[-] delay.ts
[edit]
[-] bufferToggle.ts
[edit]
[-] repeatWhen.ts
[edit]
[-] concatAll.ts
[edit]
[-] first.ts
[edit]
[-] zip.ts
[edit]
[-] elementAt.ts
[edit]
[-] skipWhile.ts
[edit]
[-] race.ts
[edit]
[-] finalize.ts
[edit]
[-] combineAll.ts
[edit]
[-] distinctUntilKeyChanged.ts
[edit]
[-] isEmpty.ts
[edit]