vuex icon indicating copy to clipboard operation
vuex copied to clipboard

lost previous registered module during multiple registration

Open musashiM82 opened this issue 3 years ago • 7 comments

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

musashiM82 avatar Nov 20 '20 15:11 musashiM82

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.

kiaking avatar Nov 22 '20 14:11 kiaking

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.

kiaking avatar Nov 22 '20 18:11 kiaking

I've opened #1883 with the failing test case.

kiaking avatar Nov 22 '20 18:11 kiaking

@kiaking what's the status of this ticket? I think most of the mentioned tickets are either resolved or closed.

vjanssens avatar Nov 22 '21 12:11 vjanssens

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.

mcrapts avatar Jan 20 '22 23:01 mcrapts

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.

lmiller1990 avatar Feb 09 '22 00:02 lmiller1990

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.

lmiller1990 avatar Feb 09 '22 01:02 lmiller1990

closed via #1883 - will release ~~patch~~ minor soon (note the new minor will require Vue 3.2+).

yyx990803 avatar Oct 14 '22 10:10 yyx990803

This still is ISSUE RIGHT?

rendomnet avatar Dec 11 '22 08:12 rendomnet

Hi everyone,

The docs (https://vuex.vuejs.org/guide/getters.html#property-style-access) still contain this warning:

image

Since this PR is closed, I think this is safe to remove now?

feliperaul avatar Mar 06 '23 21:03 feliperaul

Hi everyone,

The docs (https://vuex.vuejs.org/guide/getters.html#property-style-access) still contain this warning:

image

Since this PR is closed, I think this is safe to remove now?

Sure. PR welcome 👍

cuebit avatar Mar 06 '23 21:03 cuebit