1
votes

Moved my project from single module in vuex store to multiple following the documentation.

It states that the specific module should be accessed like so:

store.state.a // -> `moduleA`'s state

This is when accessing the state of a module. It fails to say how to access getters and mutations as well as the commands like 'commit' and 'replaceState' for a specific module so I made my own conclusion:

store.getters.a
store.mutations.a
store.a.commit()
store.a.replaceState()

1) Are those conclusions correct?

2) Using these I get a really general error message:

TypeError: rawModule is undefined

Here is my store.js:

import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
  modules: {
    listingModule: listingModule,
    openListingsOnDashModule: listingsOnDashModule,
    closedListingsOnDashModule: listingsOnDashModule
  }
})

const listingsOnDashModule = {...}
const listingModule = {...}
// their content hasn't changes since the single module approach.
1

1 Answers

5
votes

This error:

TypeError: rawModule is undefined

is caused by trying to register undefined as a module, you are probably importing undefined by accident when registering the module.

As for the syntax store.state.a is correct. With the rest the .a should just be omitted unless you are explicitly defining a namespace.