How can I only persist specific key in a Vuex Module
See original GitHub issueHello,
I have a question, How can I persist specific key in a module?:
reducer: (state) => ({
adminAccountType: state.RolesAndPermissionModule.adminAccountType,
})
I only want to persist the “adminAccountType” object within RolesAndPermissionModule , but when I do that it creates the new key in root state with “adminAccountType”
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Making only one module persistent with vuex-persistedstate
Looking at the API docs, you will need to configure the plugin to only persist a certain subset of the store. export default...
Read more >Making only some state properties persistent inside ... - Graffino
How to make only some state properties of a Vuex module persistent using the createPersistedState and reducer function.
Read more >Persist Vuex State with vuex-persist - DigitalOcean
The reducer option allows you to only store certain sections of the state. It's a simple function that gets passed the full state...
Read more >vuex-persist - npm
A Typescript-ready Vuex plugin that enables you to save the state of your app to a persisted storage like Cookies or localStorage. Paypal...
Read more >API Reference | Vuex
A module's state will be attached to the store's root state using the module's key. A module's mutations and getters will only receives...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
aliraza,
Not sure if you got an answer to this or not. Looks like it was closed pretty quickly. I was having this same problem fixed it by doing the following:
Hope that helps.
Reducer takes the state (in memory) as argument and returns the state (or its part) to be saved into your persistence.
Return whatever you want to return from reducer. Keeps keys you want. Drop keys you don’t want.
On Thu 14 Feb, 2019, 4:51 PM Malik Ali Raza <notifications@github.com wrote: