Summary
Projects each element of an observable sequence to a task with cancellation support, 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, CancellationToken, Task<TTaskResult>> taskSelector, Func<TSource, TTaskResult, TResult> resultSelector, int maxConcurrent)
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, CancellationToken, Task<TTaskResult>> |
A transform function to apply to each element. |
resultSelector |
Func<TSource, TTaskResult, TResult> |
A transform function to apply to each element of the intermediate sequence. |
maxConcurrent |
int |
Maximum number of inner observable sequences being subscribed to concurrently. |
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. |