0

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:

  • Angular 8.0.0
  • TypeScript 3.4.5
  • RxJS 6.4.0

I've just tested and dthe same thing is happening with flatMap

DoubleA
  • 1,636
  • 14
  • 28
  • I have also noticed that if I revert to RxJS 6.0.0 the error goes away without me changing any other code in my app. Trouble is, Angular 8 is dependent on RxJS ^6.4 – DoubleA Jun 13 '19 at 14:45

1 Answers1

0

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:

DoubleA
  • 1,636
  • 14
  • 28