vuexy
An static typed wrapper for vuex.
It's still a proof of concept, bugs are where, do not use in production
Usage
In main.ts
import Vuex from 'vuex'
import { Vuexy } from 'vuexy'
const store = new Vuex.Store({
})
Vuexy.init(store)
Define you vuexy module.
import { VuexyModule, Mutation, Action, Getter } from '../index'
class StoreCart extends VuexyModule {
public count: number = 0
@Mutation
add(payload?: any):void {
console.log(payload)
this.count++
}
@Action
async deferAdd():Promise<any> {
setTimeout(() => {
this.add()
}, 1000);
}
@Getter
getCount() {
return this.count
}
}
export default StoreCart.Instance<StoreCart>(StoreCart)
Use your module
<template>
{{StoreCart.count}}
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
import StoreCart from './StoreCart.ts'
@Component
export default class MyComponent extends Vue {
private StoreCart: any = StoreCart
myFunc () {
this.StoreCart.deferAdd()
.then(this.StoreCart.add)
}
count = StoreCart.count
deferAdd = StoreCart.deferAdd
add = StoreCart.add
}
</script>