Is there any way to change the persistState key based on the route
Is there any way we can pass the key dynamically, i am working on an app where same component are used in multiple tabs and need to store the user selections of this component for each tab with different key.
Right now i see the we are doing persistState as below with hard-coded key persistState('counter', { key: 'ng2-redux/examples/counter' })
I need to change the key based on the tab (implemented based on routes).
Let me know if i can do this with ng2-redux?
Hi @chinra02
persistState is actually provided by the redux-localstorage 3rd-party library, and is configurable with a range of options. Essentially the 'key' you see there is just a namespace prefix for your data in local storage; what actually gets persisted is the contents of your redux store.
You can have it persist the full store, or just parts of it as you wish: see their documentation for details: https://www.npmjs.com/package/redux-localstorage
So in your case I would save the settings for each tab in different parts of the store and let redux-localstorage persist the relevant portion of the store.
Thanks for your reply. good idea !!!