Explain the difference between switchMap, mergeMap, concatMap and exhaustMap.

Angular HTTP, RxJS and state · Freshers and experienced

Model answer

All four turn each incoming value into an inner Observable, but they differ in how they handle overlap. switchMap cancels the previous inner stream when a new value arrives (search as you type). mergeMap runs all inner streams at once (independent parallel requests). concatMap queues them and runs one after the other in order (saving edits in sequence). exhaustMap ignores new values while one is running (a login button that should not fire twice).

Tips

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions