Vue Watch

up:: Vue

NOTE

Use for any non-data update you want to make. Allows you to run any code in reaction to some changed data (eg. send http request).

Watchers are not used directly in template.

Vue.createApp({
	watch: {
		// same name as a data or computed property
		name(value) { // whenever name changes, trigger this function
			this.fullname = value + " lastname";
		}
	}
})

With a getter function

watch(
  () => wishlistItems.value?.length,
  (length) => {
    console.log("debug", length);
  }
);