Table of Contents

Class MergeScanOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Extension methods implementing the mergeScan operator.

public static class MergeScanOperator
Inheritance
System.Object
MergeScanOperator

Methods

MergeScan<TSource, TAcc>(Observable<TSource>, Func<TAcc, TSource, Observable<TAcc>>, TAcc)

Applies accumulator to each value emitted by source, subscribing to the inner observable it returns and merging its emissions into the output. The last value produced by an inner observable becomes the new accumulated state, which is passed as acc to the next call of accumulator. The output completes once source has completed and every inner observable has also completed.

public static Observable<TAcc> MergeScan<TSource, TAcc>(this Observable<TSource> source, Func<TAcc, TSource, Observable<TAcc>> accumulator, TAcc seed)

Parameters

source Observable<TSource>

The source sequence.

accumulator Func<TAcc, TSource, Observable<TAcc>>

A function called with the current accumulated state and the source value; returns an inner observable whose values become the new accumulated state.

seed TAcc

The initial accumulated state, used for the first call to accumulator.

Returns

Observable<TAcc>

An observable of the values produced by the accumulator's inner observables.

Type Parameters

TSource

The type of values emitted by source.

TAcc

The type of the accumulated state, of the values emitted by the inner observables, and of the output.

Remarks

Like MergeMapOperator, inner observables are merged with unbounded concurrency: more than one accumulator-produced observable can be active at the same time, so the retained state is updated in whatever order inner values actually arrive rather than in source-emission order. If accumulator throws, the exception is forwarded to the subscriber via OnError instead of propagating synchronously. An error from source or from any inner observable also terminates the output immediately via OnError.

MergeScan<TSource, TAcc>(Observable<TSource>, Func<TAcc, TSource, int, Observable<TAcc>>, TAcc)

Applies accumulator to each value emitted by source, along with its zero-based index, subscribing to the inner observable it returns and merging its emissions into the output. The last value produced by an inner observable becomes the new accumulated state, which is passed as acc to the next call of accumulator. The output completes once source has completed and every inner observable has also completed.

public static Observable<TAcc> MergeScan<TSource, TAcc>(this Observable<TSource> source, Func<TAcc, TSource, int, Observable<TAcc>> accumulator, TAcc seed)

Parameters

source Observable<TSource>

The source sequence.

accumulator Func<TAcc, TSource, int, Observable<TAcc>>

A function called with the current accumulated state, the source value, and its index (starting at 0); returns an inner observable whose values become the new accumulated state.

seed TAcc

The initial accumulated state, used for the first call to accumulator.

Returns

Observable<TAcc>

An observable of the values produced by the accumulator's inner observables.

Type Parameters

TSource

The type of values emitted by source.

TAcc

The type of the accumulated state, of the values emitted by the inner observables, and of the output.

Remarks

Like MergeMapOperator, inner observables are merged with unbounded concurrency: more than one accumulator-produced observable can be active at the same time, so the retained state is updated in whatever order inner values actually arrive rather than in source-emission order. If accumulator throws, the exception is forwarded to the subscriber via OnError instead of propagating synchronously. An error from source or from any inner observable also terminates the output immediately via OnError.