Skip to content

flush: 'sync' option of watchEffect is inconsistent with the behavior of Vue 3 #770

@John60676

Description

@John60676

Description

In composition-api, account change will not trigger this watch, when flush: 'sync' option is set,
but Vue 3 will trigger this watch.

setup() {
  const account = ref("John")
  const name = ref("")

  watchEffect(
    () => {
      name.value = account.value
      // in Vue 3, `account` change will trigger this watch, 
      // but in composition-api it will not
      console.log("watch")  
    },
    {
      flush: "sync",
    }
  )
  return { account, name }
}

Reproduce

Vue 2 demo: https://codesandbox.io/s/vue2-watcheffect-yebvl?file=/src/App.vue

Vue 3 demo: https://codesandbox.io/s/vue3-watcheffect-jy20t?file=/src/App.vue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions