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
Switching to a nested route is automatically running the last commit event from parent's store #1593
Comments
There's no commit triggered - the getter is re-evaluated. Which happens because regsitering a module forces vuex to re-build the whole state object, which triggers all getters that have deps to re-evaluate. This is currently required by the implementation of vuex, and we can't really change this, at least I am not aware of any ideas of how to improve his behaviour to not have this side-effect. We can probably solve it with the better reactivity in Vue 3, but not for the current version using Vue 2 The best thing to do is to check in your watchers if the state actually changed: watch: {
event: {
handler(newVal, oldVal) {
if newVal === oldVal return
switch (this.event.id) {
case 'new_requirement': {
alert('hello');
break;
}
default:
}
},
},
}, |
@farazshuja Hi! Do you have any updates on this issue? Does comment from @LinusBorg work for you? |
@kiaking Yeah, for now its the only way to go!! |
OK, thank you for the confirmation! While this could be a bit confusing, let's improve this in new version of Vuex. |
@LinusBorg this is not a solution if you are deep watching an object reference, as both Lets say you have two submodules: that is absolutely awful. is there maybe some kind of a way to hook into dependency management and make it skip watchers when vuex state is being rebuilt due to a new submodule? also, does Pinia fix this? this is the kind of breaking behaviour that would force me to say goodbye to Vuex and move to Pinia. |
你的邮件我已收到!
|
Version
3.1.0
Reproduction link
https://codesandbox.io/s/vue-template-c2gtb
Steps to reproduce
What is expected?
Route changed to reporting without showing the 'hello' alert box.
What is actually happening?
Its showing the 'hello' alert box again.
One of the releated issues
#1570
The text was updated successfully, but these errors were encountered: