-
Notifications
You must be signed in to change notification settings - Fork 378
[Feature Request] Add ignorePaths
or excludePaths
option
#288
Comments
|
@gangsthub Sorry I guess I wasn’t clear. I know this already, but I would like a way to store all paths except a few that I specify. That way when I add new root-level keys to the store, they are automatically persisted, unless I add them to |
Oh, I see what you mean. But maybe it could be "easily" added in user-land? import { modules } from '@/store'
const modulesToOmit = ['moduleSomethingSomething']
const excludeModules = module => !modulesToOmit.includes(module)
const paths = Object.keys(modules).filter(excludeModules)
// Then use `paths` constant in `path` option... What do you think? |
Yes, sure could. Thanks for sharing that code. Feel free to close this if you think it’s not worth adding as an official API. |
Let's leave that to @robinvdvleuten ;) |
The example @gangsthub provided only excludes paths at a top-level. I think that a |
Hi, I like the idea of having another attribute to exclude paths or maybe a I was wondering if it is possible to use the |
Hi. In my case, I need to persist all keys, except two. As I couldn't find any documentation about it, I tried with the "reducer" function, like this: plugins: [createPersistedState({
reducer: (state) => {
let reducer = Object.assign({}, state)
delete reducer.firstKeyToRemove
delete reducer.secondKeyToRemove
return (reducer)
}
})] Where |
A previous issue mentioned that there are some quirks with using the reducer in this way, especially if you use namespaces. I agree that having a way to exclude specific paths would be helpful. |
The
paths
option is nice, but sometimes I would like it to be the other way around and specify which paths should NOT persist.The text was updated successfully, but these errors were encountered: