watch in Vue?watch lets you run code when a specific reactive value changes. It’s like setting a listener for that value.
watchEffect differ from watch?watchEffect automatically tracks all reactive values used inside it and reruns when any of them change, without specifying dependencies manually.
watch instead of watchEffect?Use watch when you want to watch specific values and react only to their changes, especially if you want to compare old and new values.
watchEffect?Use watchEffect for side effects that depend on multiple reactive sources without manually listing them, like updating the DOM or logging.
watch or watchEffect?Both return a stop function. Call this function to stop watching and clean up resources.
watch in Vue require you to specify?watch needs you to specify which reactive value(s) to watch explicitly.
watchEffect tracks all reactive dependencies used inside its callback automatically.
watch callback that you cannot in watchEffect?watch provides old and new values to compare changes; watchEffect does not.
Both watch and watchEffect return a stop function to stop watching.
watchEffect automatically tracks all reactive dependencies inside its callback.
watch and watchEffect work in Vue and when to use each.