0👍
You should keep your mutations synchronous and also not mutate your state in actions. Consider refactoring your code.
Another issue is that your module state does indeed replace your rootState artists
.
Example:
// in store.js
state:{
artists:[]
},
mutations: {
updateArtists(state, artists) {
state.artists.push(...artists);
},
},
modules:{
artistsModule,
}
// in artistsModule.js
actions: {
updateArtists(context) {
firestore().collection('artists').limit(15).get()
.then((snapshot) => {
let artists = [];
snapshot.forEach(doc => {
artists.push({...doc.data(), id: doc.id })
});
context.commit('updateArtists', artists, { root: true });
}).catch((err) => {
console.log(err);
});
}
}
Source:stackexchange.com