-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actions lost when using persisted state? #1
Comments
Ah yes, I was coming from redux land so I hadn't put non-serializable data into store yet. I'll note this in the readme. Thanks for getting involved with this lib, having others to brainstorm with makes things so much better! If you have any ideas on how to keep non-serializable in state too while persisting it, I could try hammering it out some time after the error handling stuff. I was thinking, if the non-serializable was in |
Now that you mention it. The "thing" files are exporting a
Here's a good article on the topic. I do think Map/Set would be good to support for persist. I've got my eye on this SO answer. It doesn't have too many compromises. const serialMap = JSON.stringify(Array.from(myMap.entries()))
const myRestoredMap = new Map(JSON.parse(serialMap)) Anyway... |
I think this works because proxy behaves just like an object in all things, JSON.stringify, Object.keys, enumeration etc. So that's awesome thanks for sharing that discovery with me, I would have never known.
Map/Set support would be awesome. We would have to hold something in the persisted data to note that it is a map/set though. As the result of |
Hey @GollyJer - how is your experience been with this. I haven't been able to add in error handling yet, like if a write fails it needs a retry mechanism and after all retries it should inform the dev so he can log it to his error logger or something. Currently it's got some basic error handling with no retries. |
Hey! I ended up making a whole new version based on your ideas... but, ultimately had to abandon Valtio for now because it made our memory management issues worse. 😿 |
Ah thanks for sharing, I was suspecting Valtio was having some memory issues too with lots of data but was just a hunch. Your comment really helps. If you could share anything about those memory issues, that would be awesome, I can try to bring up with Valtio author. |
Hi! I think this is expected behavior but I thought I'd ask.
Is it expected behavior for actions to be destroyed when using actions in state.
I have a codesandbox showing the behavior here.
If you go to 👆, and click the Persisted Thing buttons before refreshing the page, it will work. But it you refresh the page and try pressing the buttons again then it will throw
persistedThing.add is not a function
error.I was hoping to keep access to all functionality under the state object but it looks like I'm going to have to break apart actions from state if I want to use persistence.
Is this a correct assumption?
The text was updated successfully, but these errors were encountered: