Search code examples
vue.jsvuexvuex-modules

About VueX good mutation practice


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 ?


Solution

  • 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