Skip to content

Instantly share code, notes, and snippets.

@championswimmer
Created July 14, 2018 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save championswimmer/0ae91192f75fa962642aecf05c30f035 to your computer and use it in GitHub Desktop.
Save championswimmer/0ae91192f75fa962642aecf05c30f035 to your computer and use it in GitHub Desktop.
import {Module, VuexModule, Mutation, Action} from 'vuex-module-decorators'
@Module
export default class Counter2 extends VuexModule {
count = 0
@Mutation increment(delta: number) {this.count+=delta}
@Mutation decrement(delta: number) {this.count-=delta}
// action 'incr' commits mutation 'increment' when done with return value as payload
@Action({commit: 'increment'}) incr() {return 5}
// action 'decr' commits mutation 'decrement' when done with return value as payload
@Action({commit: 'decrement'}) decr() {return 5}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment