-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Initialize / load existing pastStates
#75
Comments
It's not currently possible, but I love that idea! Thank you for the suggestion! |
Technically, you should be able to achieve this by using |
@charkour That worked, thanks so much! If you get the chance to take a look, I might have an enhancement suggestion here: #74 (comment) |
Hey @KrisLau, You can now initialize the temporal store with past and future states as of |
@charkour Unfortunately for my use case I can't initializing the past and future states since the user has to select the team and game then I programmatically load a bunch of info into the store from the database! However I just realized that |
Gotcha, are you using React? If so, you can use React context to initialize your zustand store after the user selects the state! |
@charkour I'm using React Native and yeah that's kind of similar to what I'm doing currently! The only difference is I have 2 contexts for the game because one depends on the value of another. Also just realized the state is being applied with the |
Gotcha, are you using this zustand dependency injection pattern with the new zundo API for initializing history? Using these two together should allow you to achieve your desired behavior and you should no longer be needing to call |
For zustand dependency injection, I made a simple helper https://github.com/charkour/zustand-di |
So I'm using zundo to add undo/redo functionality to my app but each instance of a sports game has its own state history that I need to be able to undo/redo. Is there a way i can save the
pastStates
andfutureStates
to my db and load those back into zundo?The text was updated successfully, but these errors were encountered: