Performance: Migrating from observables to signals
MEDIUM IMPACT
This affects interaction responsiveness and rendering efficiency by changing how Angular tracks and updates reactive data.
data = signal(this.service.getInitialData()); this.service.dataStream.subscribe(value => data.set(value));
this.data$ = this.service.getData(); this.data$.subscribe(value => { this.data = value; this.cd.detectChanges(); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Observable with manual subscription | Multiple updates per data change | Multiple reflows if DOM updates frequently | Higher paint cost due to redundant updates | [X] Bad |
| Signal-based reactive data | Minimal updates only on value change | Single reflow per update | Lower paint cost due to precise updates | [OK] Good |