How to do it...

We will centralize the state of our whole application in a Vuex store. To install Vuex, you can add it as a dependency (more instructions at https://vuex.vuejs.org/en/installation.html); for now, I will assume that you are working on JSFiddle or a single web page, in which you can add https://unpkg.com/vuex as a dependency.

We declare a new store for our state, as follows:

const store = new Vuex.Store({})

We then add properties to the empty object inside the parenthesis, just like we would do with a Vue instance.

First, we will tell Vuex to help us debug by noticing us every time we modify the state outside of a mutation:

strict: true

Then, we will declare the state that we will use to characterize the whole system:

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.