Performance: Watch and watchEffect
MEDIUM IMPACT
This concept affects how reactive data changes trigger component updates and side effects, impacting interaction responsiveness and rendering speed.
watch(() => reactiveProperty, () => { lightComputation(); });watch(() => largeReactiveObject, () => { heavyComputation(); }, { deep: true });| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deep watch on large object | Many DOM updates | Multiple reflows per change | High paint cost | [X] Bad |
| Watch specific reactive property | Minimal DOM updates | Single reflow per change | Low paint cost | [OK] Good |
| watchEffect with heavy computation | DOM updates blocked | Reflows delayed | High paint cost | [X] Bad |
| watchEffect with conditional light work | Minimal DOM updates | Single reflow | Low paint cost | [OK] Good |