Skip to content

tianfanfan/vuex-store-plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vuex-store-plugins

Some plugins for vuex store.

How to use

$ npm install -S vuex-store-plugins

Example

  1. 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

Explain

Wanning: action must be an async function.

  • 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.

github

License

MIT

About

一些 vuex 相关的工具

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published