I am running an Angular 8 app, and I am getting an error which seems to be a major bug in RxJS or I am missing something.
import { of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
of(1,2,3)
.pipe(
switchMap((x) => of(x + 1))
)
Now I would expect a subscriber to receive the following output:
//2, 3, 4
But instead, its outputting the actual observable that I return in the switchMap operation:
//Observable<number>, Observable<number>, Observable<number>
SUMMARY
Essentially it seems that switchMap is returning a value of type Observable<Observable<number>>
instead of just Observable<number>
.
I am not sure if this if this is a TypeScript or RxJS error, but it seems that when I revert RxJS to version 6.0.0 the issue goes away.
Versions:
I've just tested and dthe same thing is happening with flatMap
Not sure what the issue was here but I managed to resolve it. One of the following steps must have done it, but I don't know which one:
npm i rxjs@6.4 --save
)