persistState with localStorageStrategy #494
Unanswered
SatarisGIT
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Can you post the function you provide for |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I'd like to inquire about using persistState with localStorageStrategy as outlined here -> https://ngneat.github.io/elf/docs/features/persist-state/
How might I employ it to filter or manipulate the saved localStorageEntities whenever my model undergoes a change, and I aim to "migrate" it to a newer format? My localStorage harbors old data, lacking some keys, which exposes me to the risk of type errors. I wish to manually filter and verify everything comprehensively.
Currently, I am utilizing the "source" method as a persistState option, albeit not with a straightforward store.update, but with an appended setTimeout with a 0 timeout value. Absent the setTimeout, the state operates fine, values are altered but solely during runtime, without any preservation in localStorage.
In my scenario, "preStoreInit" doesn't seem to effect any changes, regardless of whether I alter or remove something. I'm uncertain about its function aside from some side logic somewhere. I fail to grasp why it necessitates the return of the store as a value, given it doesn't alter anything at all.
Are there superior alternatives? What exactly is the intent behind "preStoreInit"?
Beta Was this translation helpful? Give feedback.
All reactions