Some plugins for vuex store.
$ npm install -S vuex-store-plugins
- 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 or not.
- 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 count.