README
vuex-enhance
Enhance typescript class module support for Vuex.
Install
$ yarn add vuex-enhance
Usage
import Vue from 'vue';
import Vuex from 'vuex';
import createStore from 'vuex-enhance';
/* Todo class module */
class Todo {
/* state: keyword */
keyword = '';
/* state: data */
data: string[] = [];
/* getter: list */
get list() {
if (this.keyword) {
return this.data.filter((value) => value.includes(this.keyword));
} else {
return this.data;
}
}
/* action: add */
add(value: string): void {
if (value) {
this.data = [...this.data, value];
}
}
}
/** install vuex */
Vue.use(Vuex);
/** create store */
export default createStore({ modules: { todo } });