vuex-persisted-shared-state
v0.0.6
Published
Persist Vuex state with localStorage and share between tabs.
Downloads
2
Readme
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')