🚀[FEATURE]: storage-plugin Exclude keys from storage #1950
Replies: 7 comments
-
@DevinHolland #896 it would be better import { PersistenceState } from '@ngxs/storage-plugin';
@State({
name: 'filter',
defaults: new Filter()
})
@PersistenceState()
export class FilterState {
// ..
} You can leave your comments in issue |
Beta Was this translation helpful? Give feedback.
-
any updates on this? |
Beta Was this translation helpful? Give feedback.
-
Reading through the above issue, I don't think it had been addressed. Reopening. |
Beta Was this translation helpful? Give feedback.
-
I tried multiple approaches to "exclude" some values before storing but they weren't reliable due to HMR and other angular internals, including custom serialization/deserialization. I did successfully manage to run an action during initialization (APP_INITIALIZER) that removes those keys, each store can act to it and remove the data that shouldn't be stored in the first place. This last solution works well in all scenarios I tested except for lazy loaded stores |
Beta Was this translation helpful? Give feedback.
-
I don't think using the serialization/deserialization interceptors are a good fit in this situation. The requirement is to exclude some states from the persistent storage, while the interceptors will "act" on persisted states. My first thought about this is to mix |
Beta Was this translation helpful? Give feedback.
-
it would be ideal to be able to exclude only certain parts of the store too (per-store |
Beta Was this translation helpful? Give feedback.
-
While it would be nice to have a dedicated feature, here is how i excluded for example the states of the actions-executing plugin, to avoid incorrect executing states when the store is restored by ngxs-store.
It would however be nice if it were possible to exclude certain states from the store in a typesafe way. |
Beta Was this translation helpful? Give feedback.
-
Relevant Package
This feature request is for @ngxs/storage-plugin
Description
It'd be great if there was an option to exclude keys from persistent storage (instead of the current "include these keys" option that exists today).
Describe the problem you are trying to solve
In my application, most states should be stored in persistent storage. There are only a few that should be excluded. With the current functionality, if I had 10 states, where 9 of them should be put in localStorage, and 1 should not, I would have to list out the 9 in the "key" option. As more states are added, this list becomes very large.
In addition, I'd rather my team not have to think about which states should be included, but rather just be included by default, and only exclude when necessary. This would help reduce the cognitive load when adding new features.
Describe the solution you'd like
Something like this maybe?:
(supporting the same types as the "key" option)
Beta Was this translation helpful? Give feedback.
All reactions