Managing a single undo/redo stack for a machine and spawned actors. #1391
-
I've got a project with undoable/redoable events in it's main machine and also spawned actor machines. I'm having issues where the spawned actor machines when undoing an event, add back the event in to the undostack. I've tried adding a Has anyone else run in to something like this or have advice for how to handle this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
@dustinknopoff Do you have a codesandbox you could show us so we get a clearer idea of what you're running into? |
Beta Was this translation helpful? Give feedback.
-
Here's a great example that somebody else made: https://codesandbox.io/s/xstate-undo-redo-i3eiu In short, you maintain the undo/redo stack in |
Beta Was this translation helpful? Give feedback.
-
What I ended up doing was make another state |
Beta Was this translation helpful? Give feedback.
What I ended up doing was make another state
undo_redo
which handles all of the same events except for the event for adding to the undo/redo stack. That event, (which I've calledADD_UNDO_REDO
) just has a target of the previous state and no actions.