-
Notifications
You must be signed in to change notification settings - Fork 376
Add option to include or exclude paths #4
Comments
Good suggestion @syropian! It's added in the v1.1.0 release. Please see the README for the reducer function. |
@robinvdvleuten Hello! Thanks for the cool plugin. Can you please elaborate on how this can work? An example would be excellent. |
Hi @RashadSaleh! You can see how the functionality works by looking at the |
@robinvdvleuten
Thanks in advance. |
@Edujugon please checkout the default reducer method here. It should look something like this in (in your case); reducer (state, paths) {
// No need to use let as the reducer itself can be immutable which do not mean that the properties
are not mutable (https://ponyfoo.com/articles/var-let-const)
const reducer = Object.assign({}, state);
// state which you don't want to persist.
delete reducer.dates;
return reducer;
} Much easier is it though to give an array of paths to persist as option (https://github.com/robinvdvleuten/vuex-persistedstate#createpersistedstateoptions) |
Btw, if anyone uses vuex with namespaces and not to persist some key in any module, Object.assign is not enough. You have to deep clone your state. |
Sometimes it's easier to exclude certain paths than to manually include a bunch. If you're busy I can take a crack at this and file a PR.
The text was updated successfully, but these errors were encountered: