0.2.0 • Published 6 years ago

vuex-decorator v0.2.0

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

vuex-decorator

How to use

npm i vuex-decorator

or

yarn add vuex-decorator

Example

import { Store, Mutation, Action, Getter } from 'vuex-decorator'

@Store
class A {
  count = 0

  @Getter
  getCount (state) {
    return `count is ${state.count}`
  }

  @Mutation
  incrementSync (state) {
    ++state.count
  }

  @Action
  async increment ({ commit }) {
    setTimeout(() => {
      commit('incrementSync')
    }, 1000);
  }
}

const a = new A()

a will be

{
  state: {
    count: 0
  },
  mutations: {
    count (state, v) {
      state.count = v
    },
    incrementSync (state) {
      ++state.count
    }
  },
  actions: {
    async increment ({ commit }) {
      setTimeout(() => {
        commit('incrementSync')
      }, 1000);
    }
  },
  getters: {
    getCount (state) {
      return `count is ${state.count}`
    }
  }
}

LICENSE

MIT

0.2.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.0

6 years ago