ObservableExtensions.

ConcatMap<TSource, TCollection, TResult>(IObservable<TSource>, Func<TSource, int, IObservable<TCollection>>, Func<TSource, int, TCollection, int, TResult>) Method

Summary

Projects each element of an observable sequence to an observable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.

Syntax

public static IObservable<TResult> ConcatMap<TSource, TCollection, TResult>(this IObservable<TSource> source, Func<TSource, int, IObservable<TCollection>> collectionSelector, Func<TSource, int, TCollection, int, TResult> resultSelector)

Type Parameters

Name Description
TSource The type of the elements in the source sequence.
TCollection The type of the elements in the projected intermediate sequences.
TResult The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.

Parameters

Name Type Description
source IObservable<TSource> An observable sequence of elements to project.
collectionSelector Func<TSource, int, IObservable<TCollection>> A transform function to apply to each element; the second parameter of the function represents the index of the source element.
resultSelector Func<TSource, int, TCollection, int, TResult> A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.

Return Value

Type Description
IObservable<TResult> An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.