Performance: Signals as modern state primitive
HIGH IMPACT
Signals impact how Angular tracks and updates UI state, affecting rendering speed and interaction responsiveness.
import { Component, signal } from '@angular/core'; @Component({ selector: 'app-counter', template: `<button (click)="increment()">Increment</button><p>{{count()}}</p>` }) export class CounterComponent { count = signal(0); increment() { this.count.update(c => c + 1); } }
import { Component } from '@angular/core'; @Component({ selector: 'app-counter', template: `<button (click)="increment()">Increment</button><p>{{count}}</p>` }) export class CounterComponent { count = 0; increment() { this.count++; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Traditional property state | Full component subtree checked | Multiple reflows if DOM changes | Higher paint cost due to broad updates | [X] Bad |
| Signal-based state | Only signal consumers updated | Minimal reflows limited to changed nodes | Lower paint cost due to targeted updates | [OK] Good |