seepur/resources/scripts/applications/admin/state.vuex.ts

29 lines
557 B
TypeScript
Raw Normal View History

2020-03-17 22:16:34 +00:00
import Vue from 'vue';
import Vuex, { Store } from "vuex";
import Services from '../services';
Vue.use(Vuex);
const store = new Store({
strict: true,
state: {
users: null,
},
getters: {
users(state) {
return state.users;
}
},
mutations: {
setUsers: (state, users) => {
state.users = users;
}
},
actions: {
getUsers: async (ctx) => {
console.log('store get users');
const users = await Services.ApiService.getAllUsers();
ctx.commit('setUsers', users);
}
}
});
export default store;