vuex
vuex copied to clipboard
lost previous registered module during multiple registration
Version
4.0.0-rc.1
Reproduction link
https://github.com/musashiM82/register-module-in-before-create-page
Steps to reproduce
- clone repo
- execute
npm i && npm run serve
- open web app in browser
- in "Home" page you can see "state.home.count 1"
- click on "About" link
- click on "Home" link
- in "Home" page you can see "state.home.count" now
What is expected?
it is expected that the second time that I go into Home page I continue to see "state.home.count 1"
What is actually happening?
it is happening that I see "state.home.count". it is like the previous registered module is lost
Confirmed. This is happening due to caching issue. If we revert 0006765 it fixes. I think registering new getters is causing some kind of problem. Not sure what that is yet.
I'll look into it.
OK, this is happening because Vue is destroying the computed
(Vuex getters) when the component is destroyed (switching the route). Not because of multiple module registration.
We might not have perfect solution until https://github.com/vuejs/rfcs/pull/212 gets merged and issue https://github.com/vuejs/vue-next/issues/1532 gets solved.
Looking into any workaround we could have.
I've opened #1883 with the failing test case.
@kiaking what's the status of this ticket? I think most of the mentioned tickets are either resolved or closed.
I honestly think this will never get addressed, Vuex appears to have been abandoned in favor of Pinia, despite it being a first-party package in the Vue namespace on GitHub. This is terrible for anyone trying to migrate from Vue 2 to Vue 3.
From the docs
As of Vue 3.0, the getter's result is not cached as the computed property does. This is a known issue that requires Vue 3.1 to be released. You can learn more at PR #1878.
Well 3.1 is out - I wonder if we can fix this now. @kiaking any blocker here? Some good info here https://github.com/vuejs/vuex/pull/1883 but not entirely clear what needs to happen. I'm sure someone in the community can pick this up - I wonder if we can provide a little list of "next steps" to get this underway.
Update - 3.2 did not solve this. Kia is busy on other core projects, so, if this is an important issue for you and your project (you as in the reader of the comment), you might need to help out.
Good news is you get to fix a high impact issue! I'd recommend looking at the work in #1883 and getting an idea of what exactly the problem is (I don't know yet) but it looks like we (might) need to patch something in core.
I wonder if we can't do a memo inside of Vuex - not the cleanest solution, though. Alternatively, I wonder if we can rewrite parts of Vuex to use Proxy
which gives better change detection. The code base is quite small (Vuex) so it might not be too difficult - just throwing some ideas out there.
closed via #1883 - will release ~~patch~~ minor soon (note the new minor will require Vue 3.2+).
This still is ISSUE RIGHT?
Hi everyone,
The docs (https://vuex.vuejs.org/guide/getters.html#property-style-access) still contain this warning:
Since this PR is closed, I think this is safe to remove now?
Hi everyone,
The docs (https://vuex.vuejs.org/guide/getters.html#property-style-access) still contain this warning:
Since this PR is closed, I think this is safe to remove now?
Sure. PR welcome 👍