Skip to content

Commit

Permalink
refactor: do not mutate mutation payload in the todo app example (#1670)
Browse files Browse the repository at this point in the history
* refactor: do not mutate mutation payload in the todo app example

* refactor: make things a bit easier to read
  • Loading branch information
kiaking authored and ktsn committed Jan 27, 2020
1 parent e012653 commit bafa881
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/todomvc/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export const mutations = {
},

editTodo (state, { todo, text = todo.text, done = todo.done }) {
todo.text = text
todo.done = done
const index = state.todos.indexOf(todo)

state.todos.splice(index, 1, {
...todo,
text,
done
})
}
}

0 comments on commit bafa881

Please sign in to comment.