November 2017
Beginner to intermediate
398 pages
8h 42m
English
As we consider the state as read-only, the only way to modify it is through mutations. A mutation is a synchronous function that takes the state as the first argument and an optional payload argument, and then updates the state. It means you are not allowed to do asynchronous operations (like a request to the server) in a mutation:
const store = new Vuex.Store({ state () { /* ... */ }, mutations: { user: (state, user) => { state.user = user }, }, })
The word used to indicate that we are calling a mutation is commit. We can't directly ...
Read now
Unlock full access