Skip to content

Instantly share code, notes, and snippets.

@iparrabb
Created January 11, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iparrabb/cdb8842ff9f641a8fab284773166f170 to your computer and use it in GitHub Desktop.
Save iparrabb/cdb8842ff9f641a8fab284773166f170 to your computer and use it in GitHub Desktop.
const appModule = {
state: initialState(),
actions: {
addUser ({commit, state}, user) {
commit(types.ADD_USER, user)
},
resetState ({commit, state}) {
commit(types.RESET_STATE)
}
},
mutations: {
[types.ADD_USER] (state, user) {
state.users.push(user)
},
[types.RESET_STATE] (state) {
const initial = initialState()
Object.keys(initial).forEach(key => { state[key] = initial[key] })
}
},
getters: {
users (state) {
return state.users
},
usersLenght (state) {
return state.users.length
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment