vuex dispatch action from another module code example

Example 1: vuex call action from another action

actions:{ 
  get1: ({ commit, dispatch }) => {
    dispatch('get2');
  },
  get2: ({commit}) => {
    //things
  },
}

Example 2: how to call action from another module vuex

// action from one moduleA to moduleB
dispatch('moduleB/actionName', payload, { root:true })

Example 3: How to dispatch from another module vuex

// from the gameboard.js vuex module
dispatch('notification/triggerSelfDismissingNotifcation', {...}, {root:true})

Tags:

Misc Example