A mutation changes the state. This is where you increment and decrement stuff on the beginner tutorials. These changes are immediate.
An action is an asynchronous function. If you called a complicated vuex action, and it takes a long time to finish, it isn't preventing other components from changing the state, or calling getters.
Think of a mutation as something that is simple and there to change the state of that store. An action is where you make your HTTP Requests, prepare data for the request or the store, and the place you can call other Asynchronous methods. This also can return a promise.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Ali,
They are not the same... and I'll explain why.
A mutation changes the state. This is where you increment and decrement stuff on the beginner tutorials. These changes are immediate.
An action is an asynchronous function. If you called a complicated vuex action, and it takes a long time to finish, it isn't preventing other components from changing the state, or calling getters.
Think of a mutation as something that is simple and there to change the state of that store. An action is where you make your HTTP Requests, prepare data for the request or the store, and the place you can call other Asynchronous methods. This also can return a promise.