Performance: catchError for error handling
MEDIUM IMPACT
This affects how asynchronous errors are handled without blocking UI responsiveness or causing unnecessary re-renders.
this.dataService.getData().pipe(catchError(err => { this.error = err; return of([]); })).subscribe(data => this.data = data);
this.dataService.getData().subscribe({ next: data => this.data = data, error: err => { this.error = err; throw err; } });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Throw error inside subscribe | Multiple due to error propagation | Multiple reflows due to repeated change detection | High paint cost on error UI updates | [X] Bad |
| Use catchError with fallback | Minimal, only necessary updates | Single reflow for fallback UI | Low paint cost | [OK] Good |