Skip to content

Instantly share code, notes, and snippets.

Avatar

AndrWeisR

  • Adelaide, South Australia
View GitHub Profile
@AndrWeisR
AndrWeisR / RxJs Merge Example.md
Last active Sep 4, 2020
RxJs merge example - mergeMap, concatMap, switchMap
View RxJs Merge Example.md

Example that demonstrates the differences between mergeMap, concatMap and switchMap. Click the button to create an observable that emits 10 values in sequence, A0,A1,A2 etc.

  • mergeMap will merge multiple streams, so you get interleaved "A" values every time you click.
  • concatMap will only start emitting values after the previous sequence has completed.
  • switchMap will start emitting a new sequence after each click.

Code sandbox: https://codesandbox.io/s/rxjs-merge-examples-4wffj?file=/index.html:0-236