Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question