Binding helpers for Vuex and vue-class-component
Clone or download
Latest commit ed579ea Dec 6, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github docs: create issue template Nov 23, 2018
scripts chore: bump deps May 14, 2018
src feat: simplify namespace helper May 8, 2018
test chore: disable tips on test May 9, 2018
.gitignore Initial commit Jan 14, 2017
.travis.yml chore: update travis config Dec 6, 2018
LICENSE New year Jan 14, 2017
README.md Add Dev badge Dec 6, 2018
package-lock.json chore: tweak commands May 14, 2018
package.json chore: fix build script Dec 6, 2018
testem.yml ci: fix ci error May 14, 2018
tsconfig.base.json Bump deps fix (#8, fix #7) Apr 29, 2017
tslint.json Initial commit Jan 14, 2017

README.md

vuex-class

vuex-class Dev Token

Binding helpers for Vuex and vue-class-component

Dependencies

Installation

$ npm install --save vuex-class
# or
$ yarn add vuex-class

Example

import Vue from 'vue'
import Component from 'vue-class-component'
import {
  State,
  Getter,
  Action,
  Mutation,
  namespace
} from 'vuex-class'

const someModule = namespace('path/to/module')

@Component
export class MyComp extends Vue {
  @State('foo') stateFoo
  @State(state => state.bar) stateBar
  @Getter('foo') getterFoo
  @Action('foo') actionFoo
  @Mutation('foo') mutationFoo
  @someModule.Getter('foo') moduleGetterFoo

  // If the argument is omitted, use the property name
  // for each state/getter/action/mutation type
  @State foo
  @Getter bar
  @Action baz
  @Mutation qux

  created () {
    this.stateFoo // -> store.state.foo
    this.stateBar // -> store.state.bar
    this.getterFoo // -> store.getters.foo
    this.actionFoo({ value: true }) // -> store.dispatch('foo', { value: true })
    this.mutationFoo({ value: true }) // -> store.commit('foo', { value: true })
    this.moduleGetterFoo // -> store.getters['path/to/module/foo']
  }
}

Issue Reporting Guideline

Questions

For general usage question which is not related to vuex-class should be posted to StackOverflow or other Q&A forum. Such questions will be closed without an answer.

Bug Reports

Please make sure to provide minimal and self-contained reproduction when you report a bug. Otherwise the issue will be closed immediately.

License

MIT