1

I am having difficulty in seeing the difference between switchLatest and flatmapLatest in RxJs with the difference being one flattens a nested observable affer the fact like in scala whilst the other is the equivalent of doing it before returning the new flattened collection?

Am I missing something.

Blair Davidson
  • 901
  • 12
  • 35

1 Answers1

7

.flatMapLatest(func) is equivalent to .map(func).switchLatest(), where func outputs an observable.

André Staltz
  • 13,304
  • 9
  • 48
  • 58
  • 4
    For future readers: `switchLatest` is deprecated and renamed to just `switch` in RxJs implemenation. Also `flatMapLatest` is called `switchMap` in many RX implementations (Java, Groovy, Kotlin, Scala, RxJS5), which clearly show what it do: `map()` then `switch()`. – Ruslan Stelmachenko May 08 '16 at 10:56