Simple Vuex plugin to maintain actual version of the store. It clears localStorage if versions are not equal.
npm i https://github.com/KazanExpress/frontend-vuex-version-plugin.git
import { versionPlugin } from '@kazanexpress/vuex-version-plugin';
const plugins = [
versionPlugin({
version: 1,
name: 'store-version',
action: 'checkout/reset',
})
];
const store = new Vuex.Store({
// ...
plugins,
})
Variant 1:
In your store folder create index.js
file:
import { versionPlugin } from '@kazanexpress/vuex-version-plugin';
export const plugins = [
versionPlugin({
version: 1,
name: 'store-version',
action: 'checkout/reset',
})
];
Variant 2:
Create vuex-version.js
file in your plugins folder:
import { versionPlugin } from '@kazanexpress/vuex-version-plugin';
export default ({ store }) => {
versionPlugin({
version: 1,
name: 'store-version',
action: 'checkout/reset',
})(store);
};
In your nuxt.config.js
:
...
/*
** Plugins to load before mounting the App
*/
plugins: [
// ...
{ src: '~/plugins/vuex-version', mode: 'client' }
],
...
Option | Type | Description | Default |
---|---|---|---|
version |
Number |
Your current store version. | 1 |
name |
String |
Item key in localStorage. | "application-store-version" |
action |
String |
Store action path (could be namespaced) for triggering on clear . |
undefined |