FrontendDeveloper.in

Vue.js question detail

Why mutations should be synchronous?

You need to remember that mutation handler functions must be synchronous. This is why because any state mutation performed in the callback is essentially un-trackable. It is going to be problematic when the devtool will need to capture a "before" and "after" snapshots of the state during the mutations.

mutations: {
someMutation (state) {
api.callAsyncMethod(() => {
state.count++
})
}
}
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399