mergeMapTo
Projects each source value to the same Observable which is merged multiple times in the output Observable.
mergeMapTo<T, R, O extends ObservableInput<any>>(innerObservable: O, resultSelector?: ((outerValue: T, innerValue: ObservedValueOf<O>, outerIndex: number, innerIndex: number) => R) | number, concurrent: number = Number.POSITIVE_INFINITY): OperatorFunction<T, ObservedValueOf<O> | R>
Parameters
Returns
OperatorFunction<T, ObservedValueOf<O> | R>
: An Observable that emits items from the given
innerObservable
Description
It's like mergeMap
, but maps each value always
to the same inner Observable.
Maps each source value to the given Observable innerObservable
regardless
of the source value, and then merges those resulting Observables into one
single Observable, which is the output Observable.
Example
For each click event, start an interval Observable ticking every 1 second
import { fromEvent, interval } from 'rxjs';
import { mergeMapTo } from 'rxjs/operators';
const clicks = fromEvent(document, 'click');
const result = clicks.pipe(mergeMapTo(interval(1000)));
result.subscribe(x => console.log(x));