Watch Anything in Your Component

It took me a very long time to realize this, but anything in your component that is reactive can be watched:

export default {
  computed: {
    someComputedProperty() {
      // Update the computed prop
    },
  },
  watch: {
    someComputedProperty() {
      // Do something when the computed prop is updated
    }
  }
};

You can watch:

If you're using the composition API, any value can be watched, as long as it's a ref or reactive object.

🎉 Get 30% off Vue Tips Collection!
Get it now!