vuex-store-plugins
v1.2.1
Published
some plugins for vuex
Downloads
8
Maintainers
Readme
vuex-store-plugins
Some plugins for vuex store.
How to use
$ npm install -S vuex-store-plugins
Example
- loadingPlugins
import Vue from 'vue'
import Vuex from 'vuex'
import { loadingPlugins } from 'vuex-store-plugins'
Vue.use(Vuex)
const storeOptions = {
state: {},
mutations: {},
actions: {
async foo() {
const d = await new Promise((resolve, reject) => {
setTimeout(() => {
resolve(1)
}, 3000)
})
}
}
}
const store = loadingPlugins(Vuex, storeOptions, 'loading', true)
export default store
// * The last two parameter can be transfered,
// * The third parameter initial value is 'loadingState',
// * The fourth parameter initial value is false, if you need log set it true.
// * You will have a module named 'loading' to monitor all actions start and end.
// * Like before ,the store.state.loading.foo is monitor 'foo' action