vuex-persisted-shared-state

0.0.6 • Public • Published

vuex-persisted-shared-state

Persist Vuex state with localStorage and share between tabs.

Requirements

Installation

$ npm install vuex-persisted-shared-state

or

$ yarn add vuex-persisted-shared-state

Usage

import persistedSharedState from "vuex-persisted-shared-state";

const store = new Vuex.Store({
    // ...
    plugins: [
        persistedSharedState({
            'cart': 'SET_CART',
        }),
    ]
});

API

persistedSharedState(mutations, options = {})

Creates a new instance of the plugin with the given mutations object and options.

Mutations can be provided like strings

{
    'cart': 'SET_CART',
}

or like an objects

{
    'cart': {
        mutation: 'SET_CART',
        share: false,
        defaultValue: null,
    },
}

The following options can be provided to configure the plugin for your specific needs:

  • share: Should state change be shared between browser tabs. (default: true)
  • prefix: Prefix of the localStorage keys. (default: 'vuex-persisted-shared-state')

/vuex-persisted-shared-state/

    Package Sidebar

    Install

    npm i vuex-persisted-shared-state

    Weekly Downloads

    1

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    7.14 kB

    Total Files

    4

    Last publish

    Collaborators

    • mshekspirtt
    • max-websecret
    • blax
    • mshekspirt