Member-only story
State management with Vue.js
For those asking vue is an awesome frontend development framework for developing frontend applications.
My focus is on the aspect of state management.
You might ask what is statement management? well in simple terms, we might want to make data available to every component of our app. State management plugins give us this ability
In this article am going to talk about Vuex.
Vuex is an awesome state management library for vue. Easy to implement and use.
To use Vuex you have to first install Vuex.
This is done by entering the following command in your vuex terminal.
npm install vuex --savenext, we also have to install vuex-persist this helps to ensure state persistence in our app. Do this by entering the command below.
npm install --save vuex-persistAfter these installations, create a file called store.js preferable in your root directory. The content of store.js should look like this.
// src/store.jsimport Vue from "vue";import Vuex from "vuex";import VuexPersist from 'vuex-persist';Vue.use(Vuex);const vuexLocalStorage = new VuexPersist({key: 'my-app', // The key to store the state on in the storage provider.