How to handle mutations when using vuexfire with modules?

199 Views Asked by At

The following is written in regard of using mutations together with modules in the vuexfire documentation, together with some code snippets:

Add the mutations to your root Store and make sure to define the property you want to bind in the state first:

import { vuexfireMutations } from 'vuexfire'
const store = new Vuex.Store({
  state: {
    todos: [], // Will be bound as an array
    user: null, // Will be bound as an object
  },
  mutations: {
    // your mutations
    ...vuexfireMutations,
  },
})

It works with modules as well, but you should not add the mutations there:

const store = new Vuex.Store({
  modules: {
    todos: {
      state: {
        todos: [], // Will be bound as an array
        user: null, // Will be bound as an object
      },
    },
  },
})

The question is what is the correct way to handle mutations in a bigger project? If I have a project with about 20-30 modules, do i put all the modules mutations into the root object? Do I create an extra file for my mutations or what is the correct way to structure this?

0

There are 0 best solutions below