Performance: mergeMap vs concatMap vs exhaustMap
MEDIUM IMPACT
This concept affects how asynchronous streams are handled, impacting UI responsiveness and interaction delays.
source$.pipe(mergeMap(() => httpRequest$, 4)).subscribe();source$.pipe(concatMap(() => httpRequest$)).subscribe();
| Pattern | Concurrency | Order Guarantee | Impact on INP | Verdict |
|---|---|---|---|---|
| mergeMap | High (all concurrent) | No | Can cause race conditions and overload | [!] OK |
| concatMap | One at a time | Yes | May delay input responsiveness due to queuing | [!] OK |
| exhaustMap | One at a time, ignores new while active | No | Prevents overload, improves stability | [OK] Good |