Skip to content

Instantly share code, notes, and snippets.

@iparrabb iparrabb/reset.js Secret
Created Jan 11, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.