Performance: Getters for computed store values
MEDIUM IMPACT
This affects how quickly the UI updates when store data changes and how much CPU is used during reactive computations.
const store = reactive({ items: [1, 2, 3] }); const doubled = computed(() => store.items.map(x => x * 2)); // cached until items change
const store = reactive({ items: [1, 2, 3] }); const doubled = () => store.items.map(x => x * 2); // recalculates on every access
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Non-computed getter function | Minimal | None directly | Low but CPU-heavy | [X] Bad |
| Computed getter with caching | Minimal | None directly | Low and efficient | [OK] Good |