FlatMap is missing after upgrading to RC 6 and RxJS Beta 11

After switching to RC6 and rxjs@5.0.0-beta.11 it seems to me that several extensions from the Observable object are missing.

The flatMap operator is gone, mergeMap also does not exist. Now I see only a few operators. Any idea what I am missing?

enter image description here

+5
source share
2 answers

I think now you need to import the operators separately. If you look inside

node_modules/rxjs/add/operator/mergeMap 

you should see mergeMap.d.ts . Content of which

 declare module '../../Observable' { interface Observable<T> { flatMap: MergeMapSignature<T>; mergeMap: MergeMapSignature<T>; } } 

Thus, the mergeMap module declares both flatMap and mergeMap . So you can just import this file

 import 'rxjs/add/operator/mergeMap`; 

If you are concerned about the style (i.e. you need to import it into all the files you need), you can check out the plunker example from the Angular tutorial , where they import all the application statements into a file and simply import this file into the app.component file. It needs to be imported in only one place. In my experience, when unit testing, when AppComponent is not involved, I had to import this file into each of the test files.

+24
source

After upgrading to Angular 4, I realized that now the correct way to import flatMap is:

import {Observable} from 'rxjs / Rx' import 'rxjs / add / operator / mergeMap';

+1
source

All Articles