I'm already using modules to break down my Vuex stores into separate files but an wonder if and how you could break a stores actions into multiple files again?
Some context - I have a Products
store in a Vue based Electron application. In this I have a variety of methods to load products from a local db, download products when there are non in the local db and update products in the local db. So as i'm sure you can imagine, my actions in this store file is getting rather large.
So I've tried splitting them into 2 files so far, initial
and update
, which are then imported and merged, like so:
inital.js:
export default {
// My methods
}
update.js:
export default {
// My methods
}
products.js (store module):
import initialActions from './actions/intial';
import updateActions from './actions/update';
const actions = Object.assign(initialActions, updateActions);
Now when I call them, state, dispatch, commit
are not defined. So I'm a little stuck and somewhat reluctant to merge them back into the store file.
Structure:
- store
- modules
- products
- products.js
- actions
- initial.js
- update.js