concatMapTo operator in RxJS

The concatMapTo operator maps each source value to the given Observable innerObservable regardless of the source value, and then flattens those resulting Observables into one single Observable, which is the output Observable. Each new value emitted is concatenated to the previous value.It projects each source value to the source observable and flattens it.

Signature

concatMapTo(innerObservable, resultSelector, outerIndex): OperatorFunctionresultSelector: optional parameter
OperatorFunction: A function that emits output as observable

An example of the concatMapTo operator is given below.

const source = of( 1 , 2 , 3 );source.pipe(concatMapTo(interval( 1000 ).pipe(take( 3 )))).subscribe((val) => {console.log(val);});

And the corresponding output will be:

// 0// 1// 2// 0// 1// 2// 0// 1// 2

This is pretty much the basics of the concatMapTo operator in RxJS.

--

--