A
A
Alexey Bugaev2020-06-21 05:04:04
Vue.js
Alexey Bugaev, 2020-06-21 05:04:04

Is it possible to use actions instead of mutations?

Started learning vue. In my trial projects, when I need to change something in the store, I use actions instead of mutations, everything works as it should. But then I saw material where the action commits a mutation. Wouldn't it be a mistake not to use mutations at all? As I understand it, an action can do everything that a mutation + can do asynchronously

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tvsjke, 2020-06-21
@aleksei13b

Firstly: The only way to actually change state in a Vuex store is by committing a mutation
Secondly: when something needs to be changed in the store, mutations are used directly, they are intended for this - to change the state in the store. Action is just a wrapper over an asynchronous piece of code, which should also cause a mutation as a result.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question