Explain the difference between switchMap, mergeMap, concatMap and exhaustMap.
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
- Give one real use case for each.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- How do you call an API in Angular?
- What is an Observable, and how is it different from a Promise?
- What is the difference between subscribe and the async pipe?
- What are common RxJS operators you use, and what do they do?
- What are HTTP interceptors, and what are they used for?
- How do you handle errors from HTTP calls?