Closed Evertt closed 7 years ago
both modules will execute their version of that mutation
This is feature, so you can execute multiple handlers in different modules for the same event. Please refer to Vuex's documentation.
And with getters you get whichever module was added last to the store.
This is not intended. However, detecting duplicate getters in compilation would produce senseless error message. So I skipped it.
Okay, thank you for your explanation. And eh, is there a way to get the getters / dispatch / commit helpers that belong to only a specific module of the store?
So instead of doing const { getters, dispatch, commit } = getHelper(allCoffeeShop)
I'd do something like const { getters, dispatch, commit } = getHelper(allCoffeeShop.sweetRabbitCafe)
Only different, because that doesn't work.
You cannot. To get helper one has to make a store with all desirable modules attached.
Apparently it's possible to define getters, mutations and actions with the same name in different modules. I've noticed that when two modules use the same name for a mutation and you call that mutation by calling
commit('mutation')
then both modules will execute their version of that mutation. And the same goes for actions. And with getters you get whichever module was added last to the store.I had expected this to at least create a warning, if not a compile error. However I can imagine that TypeScript isn't able to statically type-check this. But maybe it's because you did this by design, I don't know. So uh, would you like to elaborate on that?