Skip to content

Instantly share code, notes, and snippets.

View AndrWeisR's full-sized avatar

AndrWeisR

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

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