Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/biluochun/vuex-localState
vuex plugin
https://github.com/biluochun/vuex-localState
vuex vuex-local-state vuex-plugin vuex-session-state
Last synced: about 1 month ago
JSON representation
vuex plugin
- Host: GitHub
- URL: https://github.com/biluochun/vuex-localState
- Owner: biluochun
- License: mit
- Created: 2017-07-28T01:23:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-29T08:37:09.000Z (over 6 years ago)
- Last Synced: 2024-01-02T23:39:08.573Z (5 months ago)
- Topics: vuex, vuex-local-state, vuex-plugin, vuex-session-state
- Language: JavaScript
- Size: 18.6 KB
- Stars: 18
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue. - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state ★17 - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
- awesome-vue - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Components & Libraries / Utilities)
- awesome-vuejs - vuex-local-state - Add 'localState/sessionState' options to vuex. Keep the Vuex state with localStorage. (Utilities / State Management)
README
# vuex-local-state
inject localStorage to vuex## Installation
```bash
$ npm install vuex-local-state --save
```## API
new VuexLocalState(storeOptions, [conf]);
conf default: {
namespace: '_vued',
storage: window.localStorage,
key: 'localState',
}## [Examples](https://biluochun.github.io/vuex-localState/test/index.html)
## Usage
```jsimport * as Vue from 'vue';
import * as Vuex from 'vuex';
import * as VuexLocalState from 'vuex-local-state';
import subModule from './subModule.js';const storeOptions = {
// https://vuex.vuejs.org/zh-cn/state.html
state: {},// vuex-local-state inject
// 1、 data in vuex and localStorage,
// 2、 can be a Function: function (count) { return (count || 0) + 1; }
// 3、 use: store.state.xxx
// 4、 [Not] use: store.localState.xxx
localState: {
count: oldValue => (oldValue || 0) + 1,
},actions: {},
getters: {},
mutations: {},
modules: { subModule },
};new VuexLocalState(storeOptions);
Vue.use(Vuex);
export new Vuex.Store(storeOptions);
``````js
// subModule.js
// vuex module
export default {
// https://vuex.vuejs.org/zh-cn/state.html
state: {},// vuex-local-state inject
// 1、 data in vuex and localStorage,
// 2、 can be a Function: function (count) { return (count || 0) + 1; }
// 3、 use: store.state.xxx
// 4、 [Not] use: store.localState.xxx
localState: {
aaaaa: 1,
bbbbb: null,
ccccc: oldValue => (oldValue || 0) + 1,
ddddd: (oldValue = {}) => {
if (Date.now() - (oldValue.saveTime || 0) < 60 * 1000) return oldValue;
return {};
},
},getters: {},
actions: {},
mutations: {},
};```