@batou.dev/vuex-persist-plugin
v0.1.0
Published
vuex-persist-plugin ===================
Downloads
2
Readme
vuex-persist-plugin
Vuex plugin that provides state persistence relying on a Web Storage API object.
Install
To get started using this plugin, add the dependency via npm:
npm install @batou.dev/vuex-persist-plugin
then use it as a Vuex plugin:
import Persist from "@batou.dev/vuex-persist-plugin";
const persist = new Persist<State>({
// Optional configuration properties (see below)
});
const store = createStore<State>({
state: { … },
mutations: { … },
plugins: [persist.plugin()],
});
Configuration
| Property | Type | Default | Description |
| ---------- | ----------------- | --------------------- | ------------------------------------------------------------------- |
| debounce | number | 250
| Debounce timeout duration |
| key | string | vuex-persist
| Key to store the state into |
| reduce | (state) => object | | Function to reduce the state. By default, the entire state is saved |
| storage | Storage | window.localStorage
| An object implementing the Web Storage API interface |
| unloadSave | boolean | false
| Whether or not to automatically save the state upon page unload |
Links
License
This code is licensed and distributed under the term of the MIT license.