RxJS - Transformation Operator mergeMap



In the case of mergeMap operator a project function is applied on each source value and the output of it is merged with the output Observable.

Syntax

mergeMap(project_func: function): Observable

Parameters

project_func − It takes in project_func as the argument which is applied to all the values of source observable.

Return value

It returns an Observable that has values based on the project_func applied on each value of source observable.

Example

import { of} from 'rxjs';
import { mergeMap, map } from 'rxjs/operators';

let text = of('Welcome To');
let case1 = text.pipe(mergeMap((value) => of(value + ' Tutorialspoint!')));
case1.subscribe((value) => {console.log(value);});

Output

mergeMap Operator
Advertisements