Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watchEffect within a Setup Store is stopped unexpectedly #1862

Closed
0x009922 opened this issue Dec 11, 2022 · 1 comment
Closed

watchEffect within a Setup Store is stopped unexpectedly #1862

0x009922 opened this issue Dec 11, 2022 · 1 comment

Comments

@0x009922
Copy link

Reproduction

https://stackblitz.com/edit/github-u4jlt8

Steps to reproduce the bug

  1. Click "Negate store.flag" buttonn any times you like. You will see how store.flag negates, ang how its computed store.negated stays reactive.
  2. Uncheck "Show StoreUser" input. The component will be unmounted.
  3. Check it again, to mount the component back.
  4. Click "Negate" button again - store.negated is not reactive anymore.
Screen.Recording.2022-12-11.at.14.02.35.mov

Expected behavior

I expected the watchEffect(), called within a Setup Store, to be active as long as the store's scope is active. It makes possible for utilities like computedEager() just work in setup stores.

Actual behavior

The watch effect seems to bind not to the store's setup scope, but to the component where the initial useStore invocation happened. Thus, when the component is unmounted, the watch effect is cleared and stopped, leaving the store in a broken and hard-to-debug state.

Additional information

No response

@posva
Copy link
Member

posva commented Dec 11, 2022

Created vuejs/core#7319 to track it

@posva posva closed this as completed Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants