1 import { Operator } from '../Operator';
2 import { Subscriber } from '../Subscriber';
3 import { Subscription } from '../Subscription';
4 import { OuterSubscriber } from '../OuterSubscriber';
5 import { InnerSubscriber } from '../InnerSubscriber';
6 import { ObservableInput, OperatorFunction } from '../types';
8 * Applies an accumulator function over the source Observable where the
9 * accumulator function itself returns an Observable, then each intermediate
10 * Observable returned is merged into the output Observable.
12 * <span class="informal">It's like {@link scan}, but the Observables returned
13 * by the accumulator are merged into the outer Observable.</span>
16 * Count the number of click events
18 * import { fromEvent, of } from 'rxjs';
19 * import { mapTo, mergeScan } from 'rxjs/operators';
21 * const click$ = fromEvent(document, 'click');
22 * const one$ = click$.pipe(mapTo(1));
24 * const count$ = one$.pipe(
25 * mergeScan((acc, one) => of(acc + one), seed),
27 * count$.subscribe(x => console.log(x));
34 * // ...and so on for each click
37 * @param {function(acc: R, value: T): Observable<R>} accumulator
38 * The accumulator function called on each source value.
39 * @param seed The initial accumulation value.
40 * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of
41 * input Observables being subscribed to concurrently.
42 * @return {Observable<R>} An observable of the accumulated values.
46 export declare function mergeScan<T, R>(accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, seed: R, concurrent?: number): OperatorFunction<T, R>;
47 export declare class MergeScanOperator<T, R> implements Operator<T, R> {
51 constructor(accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, seed: R, concurrent: number);
52 call(subscriber: Subscriber<R>, source: any): any;
55 * We need this JSDoc comment for affecting ESDoc.
59 export declare class MergeScanSubscriber<T, R> extends OuterSubscriber<T, R> {
67 protected index: number;
68 constructor(destination: Subscriber<R>, accumulator: (acc: R, value: T, index: number) => ObservableInput<R>, acc: R, concurrent: number);
69 protected _next(value: any): void;
71 protected _complete(): void;
72 notifyNext(outerValue: T, innerValue: R, outerIndex: number, innerIndex: number, innerSub: InnerSubscriber<T, R>): void;
73 notifyComplete(innerSub: Subscription): void;