About VueX good mutation practice

105 Views Asked by At

With a VueX store split up in modules, is it good practice to have a mutation in one module perform changes in a state from another module ?

I have a strong feeling that it is not and that module state should be modified only by mutations from within that same module. Is that right ?

1

There are 1 best solutions below

2
On BEST ANSWER

This is more of an opinionated question and it's hard to be answered without any concrete use-case nor code, but it is totally fine to interact between modules. It can be done via root, hence if it's here, it's not an anti-pattern.

It all depends of your codebase.

https://vuex.vuejs.org/api/#dispatch