Loro bisa ndjalanke side effect nanggap owah-owahan reaktif, nanging beda cara nentokake dependensi lan informasi apa kang dibiwake. Gunaake kanggo side effect (panggilan API, logging, karya DOM manual) — ora kanggo nggawe nilai (iku computed).
watch — sumber nyata, iwe nilai lawas + anyar
<script setup>
import { ref, watch } from "vue";
const searchQuery = ref("");
watch(searchQuery, (newVal, oldVal) => {
// runs ONLY when searchQuery changes; you get both values
console.log(`changed from ${oldVal} to ${newVal}`);
fetchResults(newVal);
});
</script>
