ObservableExtensions.

Reduce<TSource>(IObservable<TSource>, Func<TSource, TSource, TSource>) Method

Summary

Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. For aggregation behavior with incremental intermediate results, see System.Reactive.Linq.Observable.Scan``1(System.IObservable{``0},System.Func{``0,``0,``0}).

Syntax

public static IObservable<TSource> Reduce<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)

Remarks

The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.

Type Parameters

Name Description
TSource The type of the elements in the source sequence and the result of the aggregation.

Parameters

Name Type Description
source IObservable<TSource> An observable sequence to aggregate over.
accumulator Func<TSource, TSource, TSource> An accumulator function to be invoked on each element.

Return Value

Type Description
IObservable<TSource> An observable sequence containing a single element with the final accumulator value.