atomFamilyWithStorage #2242
Unanswered
Cpt-Falcon
asked this question in
Ideas
Replies: 1 comment 7 replies
-
I'm not exactly sure how it's different from |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
An idea that would be quite helpful for Jotai and give it a useful recoil feature would be an atomFamilyWithStorage. The atomFamilyWithStorage like with atomWithStorage would take in an identifier like 'dark mode', but it would also take in a unique identifier as well corresponding to each new atom in the family. Like a guid or an int id, whatever. Then, upon initialization in the atom family, the atom family would call a localStorageInitialization function. There it would look for the standard identifier like dark mode. It would scan through all local storage keys, looking if the string contained that dark mode identifier. If it does, we split the key string based on some kind of delimitator like a period. We would also take in a "onInitLoad" function from the user, the purpose being to parse and return the atom configured the way they want. The input to the atom would be the unique identifier as well as the content from local storage, and then would be expected to return their atom.
I was going to try and implement this myself unless it already exists
Beta Was this translation helpful? Give feedback.
All reactions