Performance: Form state tracking (dirty, touched, valid)
MEDIUM IMPACT
This affects interaction responsiveness and rendering speed during user input in forms.
this.form.controls['name'].valueChanges.pipe(debounceTime(300)).subscribe(() => { if (this.form.controls['name'].dirty) { this.showDirtyState(this.form.controls['name']); } });
this.form.valueChanges.subscribe(() => { this.updateUI(); }); updateUI() { Object.values(this.form.controls).forEach(control => { if (control.dirty) { this.showDirtyState(control); } }); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Subscribe to all form valueChanges and update UI immediately | High (all controls checked) | Multiple per keystroke | High (many style/layout recalculations) | [X] Bad |
| Subscribe to specific controls with debounce and conditional updates | Low (targeted controls only) | Single per pause | Low (minimal style/layout recalculations) | [OK] Good |