Skip to content

,System.Func{--1},System.Func{--1,--0,--1})} ,System.Func{--1},System.Func{--1,--0,--1},System.Func{--1,--1})}

Observable.Collect(IObservable, Func, Func) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IEnumerable<TResult> Collect<TSource, TResult>(this IObservable<TSource> source, Func<TResult> newCollector, Func<TResult, TSource, TResult> merge)
  • 2. public static IEnumerable<TResult> Collect<TSource, TResult>(this IObservable<TSource> source, Func<TResult> getInitialCollector, Func<TResult, TSource, TResult> merge, Func<TResult, TResult> getNewCollector)

1. Overload

public static IEnumerable<TResult> Collect<TSource, TResult>(this IObservable<TSource> source, Func<TResult> newCollector, Func<TResult, TSource, TResult> merge)

Summary: Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements produced by the merge operation during collection.

Parameters

NameTypeDescription
sourceIObservableSource observable sequence.
newCollectorFuncFactory to create a new collector object.
mergeFuncMerges a sequence element with the current collector.

Returns: IEnumerable -- The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or newCollector or merge is null.

2. Overload

public static IEnumerable<TResult> Collect<TSource, TResult>(this IObservable<TSource> source, Func<TResult> getInitialCollector, Func<TResult, TSource, TResult> merge, Func<TResult, TResult> getNewCollector)

Summary: Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements produced by the merge operation during collection.

Parameters

NameTypeDescription
sourceIObservableSource observable sequence.
getInitialCollectorFuncFactory to create the initial collector object.
mergeFuncMerges a sequence element with the current collector.
getNewCollectorFuncFactory to replace the current collector by a new collector.

Returns: IEnumerable -- The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or getInitialCollector or merge or getNewCollector is null.