Mutations are the only way to modify application state. They make updating state in an atomic and synchronous way easy to reason about.
This lesson will show you how to modify state by using Vuex Mutations. We will add type-safety with TypeScript using the @Mutation
decorator (imported from vuex-class
).
Did not fully get how making a copy of newTodo object, made the @keyup.enter work? Is it because the newTodo argument inside addTodo is referencing the reactive DATA property of that vue component?
First it passes the object that it's being used for the input value, and object are passed by reference, so it's always the same one. That's why you need to create a new one.