Reset an actor to a snapshot #4829
Unanswered
jonestristand
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be very useful to be able to reset an actor to a snapshot without having to create a new actor (e.g. reset to the state and context in a snapshot from
getPersistedSnapshot
). For instance,actor.resetFromSnapshot
.In my use case I need to have an undo function where the entire series of steps taken through the state machine can be eplayed in reverse order. The first part of this is easy: I subscribe to the actor and with each change take a persisted snapshot and store it in a stack. When stepping backwards however I have to recreate a new actor for each step. This is more difficult as well since I store the actor in a react context and this can cause unnecessary re-renders of some components.
Adding this feature should be fairly easy to do. I would propose that it explicitly does not perform any of the side effects in the statepath up to the point of the snapshot, but rather just resets the actor to the state in the snapshot - this can be made clear in the docs.
Beta Was this translation helpful? Give feedback.
All reactions