Skip to content

KazanExpress/frontend-vuex-version-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@kazanexpress/vuex-version-plugin

Simple Vuex plugin to maintain actual version of the store. It clears localStorage if versions are not equal.

Installation

npm i https://github.com/KazanExpress/frontend-vuex-version-plugin.git

Usage

Vue + Vuex application

import { versionPlugin } from '@kazanexpress/vuex-version-plugin';

const plugins = [
  versionPlugin({
    version: 1,
    name: 'store-version',
    action: 'checkout/reset',
  })
];

const store = new Vuex.Store({
  // ...
  plugins,
})

Nuxt application

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' }
  ],

  ...

Options

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published