Skip to content

Instantly share code, notes, and snippets.

Created December 26, 2017 15:52
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 anonymous/70cf97999c994905292fa777e16cbcc0 to your computer and use it in GitHub Desktop.
Save anonymous/70cf97999c994905292fa777e16cbcc0 to your computer and use it in GitHub Desktop.
mutations: {
[types.SET_POSTS]: (state, response) => {
state.posts = response.data
},
[types.SET_POST]: (state, response) => {
state.current_post = response
},
[types.PUSH_POST]: (state, response) => {
state.posts.push(response)
},
[types.SPLICE_POST]: (state, _id) => {
state.posts = state.posts.filter(post => post._id !== _id)
}
},
mutations: {
addTodo (state, { text }) {
state.todos.push({
text,
done: false
})
},
deleteTodo (state, { todo }) {
state.todos.splice(state.todos.indexOf(todo), 1)
},
toggleTodo (state, { todo }) {
todo.done = !todo.done
},
editTodo (state, { todo, value }) {
todo.text = value
},
toggleAll (state, { done }) {
state.todos.forEach((todo) => {
todo.done = done
})
},
clearCompleted (state) {
state.todos = state.todos.filter(todo => !todo.done)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment