pinia-plugin-persistedstate
pinia-plugin-persistedstate copied to clipboard
[core] Add excluded paths option
Clear and concise description of the problem
The suggestion is to add an option to exclude paths. This allows for more fine-grained persistence without requiring to change store structure:
persist: [{
key: 'foo-unsecure',
paths: ['foo'],
excludedPaths: ['foo.bar', 'foo.baz'],
storage: localStorage
}, {
key: 'foo',
paths: ['foo.bar', 'foo.baz'],
storage: sessionStorage
}]
Suggested solution
let toStore = state;
if (paths?.length) {
toStore = pick(toStore, ...paths);
}
if (excludedPaths?.length) {
toStore = omit(toStore, ...excludedPaths);
}
Alternative
No response
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guide.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Hi, this is a fairly easy enhancement that can be considered! I'll try to do it asap :)
Happy to do this, if the issue is still open for assignment?
Hi @marktlinn it still is, the requirements are to use no external libraries, and keep the code as small and readable as possible 😄