0 votes
in VueJS by
Why mutations should be synchronous?

1 Answer

0 votes
by

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++
    })
  }
}

Related questions

0 votes
asked Sep 12, 2023 in VueJS by GeorgeBell
0 votes
asked Sep 7, 2023 in VueJS by DavidAnderson
...