Closed John60676 closed 3 years ago
This PR https://github.com/vuejs/composition-api/pull/724 could solve the issue, but it's not the best solution.
I think the reason for this problem is this:https://github.com/vuejs/composition-api/blob/9566e6363da289951073ac5b29810c0577a64648/src/reactivity/reactive.ts#L97
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.
sorry for the bad English
Has been solved by https://github.com/vuejs/composition-api/pull/786.
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