Vuex: I wanna call dispatch inside a module, and from a function that doesn't belong to mutations or actions

Code bellow shows what I want to do.
Please check out.

// 
// store/modules/test.js
//
.....

const mutations = {
 .....
}

const actions = {
 .....
 deleteAllAboutThisID ({ commit }, payload) { // payload = {id}
   let id = payload.id;
   // call commit below
 },
 .....
}

// This function is a callback of some API, and the first argument must be msg,
// so the function can't be placed inside of actions.
function handleMessage (msg) { 
 let type = msg.type;
 let payload = msg.payload;

 switch (type) {
  case 'deleteAll':
   // I wanna call dispatch() here to trigger one of the actions of this module, like,
   // dispatch('deleteAllAboutThisID', {id: id});
 }
}

default export {
 namespased: true,
 state,
 getters,
 mutations,
 actions
}

Any ideas?

One solution might be

  1. Prepare a js file like
//
// store/modules/utils/handleMessage.js
//
import store from 'store/index';

function handleMessage (msg) { 
 let type = msg.type;
 let payload = msg.payload;

 switch (type) {
  case 'deleteAll':
   store.dispatch('test/deleteAllAboutThisID', {id: paylaod.id});
 }
}

export handleMessage;
  1. And import that function in the module (test.js) and then use it.

But this includes circular dependency, since test.js is also imported in store/index.js