You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But there's no real answer on this question, in manual mode it does work properly, but in dynamic it doesn't, because browser refresh doesn't re-apply state values from local storage. Kinda the same guy involved in both of these projects @championswimmer, but they are not compatible? :)
The text was updated successfully, but these errors were encountered:
mabe I have a solution for this,I write a vuex plugin by hijacking the store.registerModule in vuex
here is the code
maybe someone can make a optimization for this
I think it could be a better solution
//#region [rgba(0,205,20,0.1)]
const dynamicRegisterPlugin = (store: Store<IRootState>) => {
// Override dynamic module handling in vuex
let origRegisterModule: any
if (store.registerModule) {
origRegisterModule = store.registerModule.bind(store)
// your module interfaces
type T = IAppState | IUserState | IPermissionState | ITagsViewState | ISettingsState | IHome
//@ts-ignore
store.registerModule = (
path: string,
module: Module<T, IRootState>,
options?: ModuleOptions
) => {
// console.log(store)
if ((store.state as Object).hasOwnProperty(path)) {
origRegisterModule(path, module, { preserveState: true })
} else {
origRegisterModule(path, module, options)
}
// origRegisterModule(path, module, options)
}
}
}
//#endregion
const vuexLocal = new VuexPersistence<IRootState>({
storage: window.sessionStorage
})
// Declare empty store first, dynamically register all modules later.
export default new Vuex.Store<IRootState>({
plugins: [dynamicRegisterPlugin, vuexLocal.plugin]
})
This is related to following issues:
But there's no real answer on this question, in manual mode it does work properly, but in dynamic it doesn't, because browser refresh doesn't re-apply state values from local storage. Kinda the same guy involved in both of these projects @championswimmer, but they are not compatible? :)
The text was updated successfully, but these errors were encountered: