Skip to content

Instantly share code, notes, and snippets.

@lakshyabatman
Last active May 6, 2020 11:57
Show Gist options
  • Save lakshyabatman/90b1366929fb924ed2ce85481d7b0c16 to your computer and use it in GitHub Desktop.
Save lakshyabatman/90b1366929fb924ed2ce85481d7b0c16 to your computer and use it in GitHub Desktop.
A Simple class based vuex module
import { VuexModule, Module, getModule, MutationAction } from 'vuex-module-decorators';
import store from '../index';
@Module({
namespaced: true,
name: 'counter',
store: store,
dynamic: true,
})
class CounterModule extends VuexModule {
counter : number = 0;
@MutationAction({})
async increment() {
let temp: number = this.counter + 1;
return {counter : temp }
}
@MutationAction({})
async decrement() {
let temp: number = this.counter - 1;
return {counter : temp }
}
get getCounter() {
return this.counter;
}
}
export default getModule(CounterModule);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment