Skip to content

Instantly share code, notes, and snippets.

@derpdead
Last active December 17, 2019 12:01
Show Gist options
  • Save derpdead/a1983380b35b5550cb84f55305220826 to your computer and use it in GitHub Desktop.
Save derpdead/a1983380b35b5550cb84f55305220826 to your computer and use it in GitHub Desktop.
Example of basic Vuex state
export default {
setId({ commit }, id) {
commit(types.SET_ID, id);
},
setCode({ commit }, code) {
commit(types.SET_CODE, code);
},
setType({ commit }, type) {
commit(types.SET_TYPE, type);
},
setGroups({ commit }, groups) {
commit(types.SET_GROUPS, groups);
},
}
export default {
[types.SET_ID](state, id) {
state.id = id;
},
[types.SET_CODE](state, code) {
state.code = code;
},
[types.SET_TYPE](state, type) {
state.code = type;
},
[types.SET_GROUPS](state, groups) {
state.groups = groups;
},
}
export default () => ({
id: null,
code: '',
type: '',
groups: [],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment