Modify State by using Vuex Mutations with TypeScript

Share this video with your friends

Send Tweet

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).

haris
~ 7 years ago

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?

Alex Jover Moralesinstructor
~ 7 years ago

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.

Nima
~ 7 years ago
Nima
~ 7 years ago