Performance: Signal-based components
HIGH IMPACT
Signal-based components improve rendering speed by updating only the parts of the UI that depend on changed signals, reducing unnecessary work.
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 |
|---|---|---|---|---|
| Normal property with Angular change detection | Full component subtree checked | Multiple reflows if many bindings update | Higher paint cost due to more updates | [X] Bad |
| Signal-based reactive property | Only affected bindings update | Minimal reflows triggered | Lower paint cost due to targeted updates | [OK] Good |