Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Vuex Quick Start Guide

You're reading from   Vuex Quick Start Guide Centralized State Management for your Vue.js applications

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788999939
Length 152 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Andrea Koutifaris Andrea Koutifaris
Author Profile Icon Andrea Koutifaris
Andrea Koutifaris
Arrow right icon
View More author details
Toc

Developing an undo/redo plugin

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image