Performance: tap operator for side effects
MEDIUM IMPACT
This affects the responsiveness and smoothness of UI updates by controlling side effects in reactive streams without altering the data flow.
observable$.pipe(tap(value => { lightSideEffect(value); })).subscribe();observable$.subscribe(value => { heavySyncSideEffect(value); });| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy synchronous side effects inside subscribe | No direct DOM ops | Blocks main thread causing delayed reflows | High paint cost due to jank | [X] Bad |
| Lightweight side effects inside tap operator | No direct DOM ops | No blocking, smooth reflows | Low paint cost, smooth UI | [OK] Good |