0.1.0 • Published 3 years ago

@batou.dev/vuex-persist-plugin v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

PropertyTypeDefaultDescription
debouncenumber250Debounce timeout duration
keystringvuex-persistKey to store the state into
reduce(state) => objectFunction to reduce the state. By default, the entire state is saved
storageStoragewindow.localStorageAn object implementing the Web Storage API interface
unloadSavebooleanfalseWhether 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.