Constantin Druccdruc

Hey, I'm Constantin Druc!

I'm a web developer sharing everything I know about building web applications.

Vue 3 - watch multiple values

Recently I had a situation in Vue that involved watching multiple values and then acting based on their changes.

Here's how you can do it:

  () => [form.available_in_stores, form.available_online],
  ([availableInStores, availableOnline]) => {
    if (!availableInStores && !availableOnline) {
      form.is_sellable = false;

However, at least for the example above, you can also combine the watched values:

  () => form.available_in_stores || form.available_online,
  isSellable => (form.is_sellable = isSellable)