Problem Statement
How do the immediate and deep options in watch() work?
Explanation
immediate: true runs the watcher once on setup with the current value. deep: true traverses nested objects/arrays so changes to inner properties trigger the watcher. Deep should be used carefully due to performance cost.
Code Solution
SolutionRead Only
watch(state, (nv, ov) => save(nv), { deep: true, immediate: true })