Reactive Vue Storage
npm install revuestshell
$ npm install revuest
`
###### Basic Usage
`javascript
// main.js
import Vue from "vue";
import App from "App.vue";
import revuest from "revuest";
Vue.use(revuest);
new Vue({
el: "#app",
render: h => h(App)
});
`
`html
{{ localStorage.message }}
`
$3
Revuest uses Vue.mixin method to inject four properties to every instance of Vue: the __localStorage__ and __sessionStorage__, that are used for accessing the stored key-value pairs, and the __$localStorage__ and __$sessionStorage__, that exposes wrappers to the browser's native storage objects functions get, set, delete, clear and other functions.
As long as the key-value pairs exist on the browser storage, they can be accessed from within templates like any other properties.
The plugin also uses the Vue.watch function and the browser's native storage event to make the localStorage and sessionStorage objects reactive, which means that when the value is changed in one side, the data will be reflected on the other side.
That means it can be used inside inputs and other html elements like bellow:
`html
`
But note that due to Vue.watch limitation to watch for new properties, the code above only works if the data is already set on the storage before the Vue instance get created.
In order to solve that, use the beforeCreate hook to initialize the storage like the example bellow:
`html
``