You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In composition-api, account change will not trigger this watch, when flush: 'sync' option is set,
but Vue 3 will trigger this watch.
setup(){constaccount=ref("John")constname=ref("")watchEffect(()=>{name.value=account.value// in Vue 3, `account` change will trigger this watch, // but in composition-api it will notconsole.log("watch")},{flush: "sync",})return{ account, name }}
When observe is executed, target will change to accessor mode. Target must have getter/setter.
When the setter is triggered, getter.call(target) will collect dependencies.
That's why dependencies are collected despite assignment
I know this code is to avoid the data that is originally accessors, but this logic already exists in defineReactive, why repeat implementation.
Description
In composition-api,
account
change will not trigger this watch, whenflush: 'sync'
option is set,but Vue 3 will trigger this watch.
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
The text was updated successfully, but these errors were encountered: