Hi, I believe it was possible before to selectively purge keys from the root reducer. I don鈥檛 see any provided functionality to keep some settings during a purge. I don鈥檛 want my app user to have to re-enter stuff like settings (api keys etc).
Any idea how to do that elegantly?
Does the blacklist feature not do what you need it to do? Keys in the blacklist will not be persisted.
https://github.com/rt2zz/redux-persist#blacklist--whitelist
No, I mean to exclude some keys from purging, not from storing...
I did manage to give the reducer I wanted to NOT be flushed it's own key and blacklisted it from the main reducer, which made the storage go proper, but then when I do a purge on the store, it still purges everything. Which makes sense since it's a store purge. Maybe offer a reducer purge?
Now I purge directly via storage.removeItem. Feels dirty ;]
Why did you close this? It鈥檚 still valid
Sorry, I misunderstood your question when I originally answered/closed.
So this seems like a feature request, right? Would you recommend the API to be an argument to .purge()? Want to provide an example? I personally don't use .purge() in my project so feel free to provide more details on what you'd like to see.
I believe it was possible before
Was this in v4? Looking at the API...
Maybe I am mistaken, but in my code I was actually doing that. I just started upgrading a year+ old project, so it was from end 2017.
So yes, if it's not in there now, it would be nice if purge would not be store wide, but instead scoped to a reducer
Since we are stuck with this discussion and I don't see my suggestion for configuration realized anytime soon, I added my insights to this discussion here: https://github.com/rt2zz/redux-persist/issues/892
Any updates on this? can I help to review this in order to speed it up?
This did exist in v4 and was very helpful
https://github.com/rt2zz/redux-persist/tree/v4.10.2#persistor-object
- purge(keys)
- keys array An array of keys to be purged from storage. If not provided all keys will be purged.
It looks like this has been removed in v5? If that's correct, is there another way to do it?
What's the use case for purging over dispatching an action that could remove specific keys/values? If this feature does land, I definitely think it should be seen as an experimental and opt-in feature, as something like that can easily break consumers' codebases.
But I still contest that one should simply dispatch an action that does this. Using redux-persist to do that feels hacky and adds another moving part to your codebase.
@iamclaytonray Our app was using it with a "clear cache" button to reset parts of our app. Now I have to add handlers in each reducer I want to clear which works, but is a little annoying.
Most helpful comment
This did exist in v4 and was very helpful
https://github.com/rt2zz/redux-persist/tree/v4.10.2#persistor-object
It looks like this has been removed in v5? If that's correct, is there another way to do it?