I have an action and a global change in a namespace module (i.e. not in the module). I want to be able to commit global changes in the action.
//Global changes export default { globalMutation (state, payload) { ... } } //Actions in namespace modules export default { namespaced: true, actions: { namespacedAction ({ commit, dispatch, state }, payload) { commit({ type: 'globalMutation' }) } } } When dispatching a namespace action, Vuex displays:
[vuex] unknown local mutation type: globalMutation, global type: module/globalMutation
Can I invoke this global change by passing an option to the commit function?
Looks like I just found a way to do this using the
{ root: true }parameter.commit('globalMutation', payload, { root: true })If the module has a namespace, use the global path instead:
commit('module/mutation', payload, { root: true })