RxJS mergeMap vs concatMap vs switchMap - gecko-8/devwiki GitHub Wiki

Up

All three:

  • Are used in the pipe on a single source observable
  • Allow interaction with a second (inner) observable
  • Result in a new observable based on the original two

concatMap

  • Subscribe to observables in sequence, processing each in it's entirety before moving on to the next

mergeMap

  • Processes each observable in it's entirety but interleaves the results based on when the value was received

switchMap

  • Similar to mergeMap but inner observables are cancelled as soon as a new value is received from the outer observable