DEV Community

Discussion on: Quick guide to Vuex

Collapse
 
daradedesign profile image
Dallas DeGrendel

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.