Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1
Large Application Patterns with Vuex Chapter 18

You can actually undo the mutation with that, as shown in the following illustration:


Note how the state didn't change when clicking the time travel option; that's because the


purple ribbon is still at the last state. To examine a different state, just click on the name of
the mutation itself.


This debug mechanism is possible because mutations are always synchronous; this means


that it's possible to take a snapshot of the state before and after the mutation and navigate
through time. In the next recipe, you will learn how to use Vuex to perform asynchronous


actions.


Listing your actions in Vuex


All your mutations must be synchronous, so how do you do things such as waiting for a


timeout or using Axios for an AJAX request? Actions are the next level of abstraction that
will help you with this. Inside an action, you can commit multiple mutations and make


asynchronous operations.

Free download pdf