Let's say we have a store with two modules, A and B.
All I need is: Access a state property of A while initializing the state of B.
Accessing that property can be done with 'rootState' if the case was trying to access the property inside a getter, action or mutation. But how can I do that while initializing the state?
Example:
A.js
export default {
state:{
x:5
}
}
B.js
export default {
state:{
foo: 3+ (how to access A.x here?) // this should be 8
}
}
index.js would look something like this
import moduleA from './modules/A'
import moduleB from './modules/B'
new Vuex.Store({
modules: {
A: moduleA,
B: moduleB,
},
})