The Google Analytics plugin we just coded is a good and simple example of how the Vuex plugin system can be exploited to add features to your application, without touching the application core code. But what about a more complex plugin? Is the Vuex plugin also suited for more complex operations? Well, of course, it is! In the following pages, we will develop an undo/redo plugin, which is still a simple, but not trivial example.
We can exploit the fact that, in using the Vuex system, we have a single centralized state and this state can only be modified by mutations. The idea is to take a snapshot of the state each time it gets modified. Then, to go back in the mutation history, it is enough to set the current state to a snapshot, representing an older state before the mutation occurred.
Let's start by creating a plugin that registers a module...