I think I would go with a top-level kind of history machine like in your last example, to keep the concerns of the machines separated.
One way you could go about this is to implement the Command Pattern with undoable commands.
This works well because your history machine just needs to keep a stack of the commands in memory, as opposed to a stack of ALL previous (and some future) state.
Hey Robert,
thanks for the answer.
Yes one classical way is using Command Pattern, now what I'm trying to get around is how to model that using XState (or not, maybe taking that out of Xstate) in an elegant and safe way.
I will also make this question on spectrum.chat/statecharts to see what other suggestions might come up.
Thanks a lot :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Rui,
That's a good question!
I think I would go with a top-level kind of history machine like in your last example, to keep the concerns of the machines separated.
One way you could go about this is to implement the Command Pattern with undoable commands.
This works well because your history machine just needs to keep a stack of the commands in memory, as opposed to a stack of ALL previous (and some future) state.
Hope that helps!
Hey Robert,
thanks for the answer.
Yes one classical way is using Command Pattern, now what I'm trying to get around is how to model that using XState (or not, maybe taking that out of Xstate) in an elegant and safe way.
I will also make this question on spectrum.chat/statecharts to see what other suggestions might come up.
Thanks a lot :)