Created
August 15, 2019 13:13
-
-
Save YuraKolesnikov/d7c0206930b131041e08857752bd3d34 to your computer and use it in GitHub Desktop.
vuex-persistedstate performance in modular Vuex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Vuex from 'vuex' | |
Vue.use(Vuex) | |
import { testStorage } from './modules/test' | |
export default new Vuex.Store({ | |
modules: { | |
testStorage | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TestPlugin } from '../plugins/TestPlugin' | |
export const testStorage = { | |
state: { | |
value: '' | |
}, | |
mutations: { | |
changeValue: (state, value) => state.value = value | |
}, | |
getters: { | |
getValue: state => state.value | |
}, | |
actions: { | |
actionValue: ({state, commit, rootState}) => { | |
commit('changeValue', 'YEET') | |
} | |
}, | |
plugins: [TestPlugin] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import VuexPersistedState from 'vuex-persistedstate' | |
export const TestPlugin = VuexPersistedState({ | |
key: 'test', | |
storage: window.localStorage, | |
paths: ['value'] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment