Summary
Projects each element of an observable sequence to a task by incorporating the element's index, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
Syntax
public static IObservable<TResult> MergeMap<TSource, TTaskResult, TResult>(this IObservable<TSource> source, Func<TSource, int, Task<TTaskResult>> taskSelector, Func<TSource, int, TTaskResult, TResult> resultSelector)
Type Parameters
Name |
Description |
TSource |
The type of the elements in the source sequence. |
TTaskResult |
The type of the results produced by the projected intermediate tasks. |
TResult |
The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results. |
Parameters
Name |
Type |
Description |
source |
IObservable<TSource> |
An observable sequence of elements to project. |
taskSelector |
Func<TSource, int, Task<TTaskResult>> |
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, TTaskResult, 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. |
Return Value
Type |
Description |
IObservable<TResult> |
An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element. |