Created
December 26, 2017 15:52
-
-
Save anonymous/70cf97999c994905292fa777e16cbcc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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