Created
January 15, 2019 01:47
-
-
Save DezChuang/3d6a049d960fa9f893893a71004ffaa2 to your computer and use it in GitHub Desktop.
/plugins/register-store.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function registerStore({ module, moduleName, store }) { | |
const moduleIsRegistered = | |
store._modules.root._children[moduleName] !== undefined | |
const stateExists = store.state[moduleName] | |
if (!moduleIsRegistered) { | |
store.registerModule(moduleName, module, { preserveState: stateExists }) | |
} | |
} | |
export default ({ app }, inject) => { | |
inject('registerStore', registerStore) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment