Performance: Why observables matter in Angular
MEDIUM IMPACT
Observables affect how Angular handles asynchronous data streams, impacting interaction responsiveness and rendering updates.
items$ = this.dataService.getData(); // use async pipe in template
this.dataService.getData().subscribe(data => { this.items = data; });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Direct subscribe in component | Multiple DOM updates per emission | Multiple reflows per update | High paint cost due to frequent updates | [X] Bad |
| Async pipe with observable | Minimal DOM updates only on new data | Single reflow per update | Lower paint cost with efficient updates | [OK] Good |