Last active
May 6, 2020 11:57
-
-
Save lakshyabatman/90b1366929fb924ed2ce85481d7b0c16 to your computer and use it in GitHub Desktop.
A Simple class based vuex module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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