Generating a FSM at runtime #4646
Unanswered
brandonchinn178
asked this question in
Q&A
Replies: 1 comment 2 replies
-
@brandonchinn178 - did you find a workaround for this ? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my application, I ask the user for the number of players, and then start the game. As a simplified explanation, each player is represented as a state and can transition to the next player. So I need to generate a machine at runtime with the number of states corresponding to the number of players.
When I do so, it works perfectly, except now I can't persist the machine, since "An inline child actor cannot be persisted". I understand why that's true generally (#4410), since "Actor" is just an interface on top of a transition function, and you can't persist a function. But for my specific use case where the child actor is a state machine,
childActor.getPersistedSnapshot()
does work. Is there some other reason why an actor backed by a generated state machine can't be persisted?Of course, perhaps I'm running into issues because this isn't how I'm supposed to use xstate. Is there a better / more idiomatic way to model this?
A simplified example:
Beta Was this translation helpful? Give feedback.
All reactions