Angular 7: flatMap is not a function

743 Views Asked by At

I am migrating from angular 5 to angular 7, its when I am getting this error when I do npm start.

const config = this.router.events.pipe(
skipWhile(() => !this.router.navigate),
take(1),
flatMap(() => this.route.queryParams.pipe(take(1)).flatMap(params => {

Other details as below:

private route: ActivatedRouter
private router: Router
rxjs version is ^6.3.3

Replacing flatMap with MergeMap is a good option? If so, do I need to change the code as well? What should I do?

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

You need to add flatMap inside pipe operator like you did with take(1)

try this:

this.route.queryParams.pipe(take(1), flatMap(params => {
})
0
On

Yes replacing flatMap with mergeMap is a good option as they are the same thing. At some point flatMap was renamed to mergeMap. It should not be necessary to do any changes to the code if you use mergeMap.