The difference between mutations and actions in Vuex, vuexmutations
The difference between actions and mutations is not to solve the problem of competition,To use devtools to track status changes.
In fact, in vuex, actions is just a concept of atomicity. It is not necessary. In the end, it is just a function. you can do everything you want in it, as long as mutation is triggered. How to deal with asynchronous competition is the user's own business.
What vuex really limits you is that mutation must be synchronized (in redux, it is like CER must synchronously return to the next state ). The significance of synchronization is that after each mutation is executed, it can correspond to a new State (the same as CER), so that devtools can save a snapshot, then you can choose time-travel. If you open devtool to call an asynchronous action, you can clearly see when the mutation called by it is recorded, and you can immediately view their corresponding status.
Test:If an asynchronous operation is performed in mutation, a snapshot will be immediately printed in dev-tools. At this time, the asynchronous operation has not been completed, and the snapshot information is incorrect.
In the action, dev-tools will wait until the asynchronous operation is executed to print a snapshot of mutation, so that we can check the time-travel, view the changes in a mutation.
The differences between mutations and actions in Vuex above are all the content that I have shared with you. I hope you can give us a reference and support the help house.