vue
vue copied to clipboard
$subscribe triggered when unrelated store used for first time in child component (Vue 2)
Reproduction
~~https://codesandbox.io/s/pinia-store-usage-in-child-component-triggers-subscribe-in-different-unrelated-store-nvhwq8~~
https://jsfiddle.net/posva/z0qbvLr3/
Steps to reproduce the bug
Click on change
Expected behavior
The watcher doesn't trigger
Actual behavior
The watcher triggers
This seems to happen with plain Vue 2: https://jsfiddle.net/posva/z0qbvLr3/ but not with Vue 3
it might be a limitation of the reactivity system not using Proxies... I moved it to vue repo just in case
This is an edge case due to Vue 2's new property addition check working differently compared to Vue 3.
In Vue 3 we use Proxy for proper detection, but in Vue 2 we do this by registering the parent object itself as the change source. The deep
flag is also causing the watch callback to always run as long as any dependency change. So unfortunately this is an edge case due to Vue 2's reactivity limitations.