Feedback on this pattern that I come up during learning XState. #3871
azamuddin
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary:
I want to split machine into smaller machines with it's own context and transitions, so clearly I can't use hierarchical state.
It perhaps can be done with parent-child machines, but I find it quite cumbersome for my case and too many duplication needed, overall IMO it introduce more complexities than reducing it.
So, I take inspiration from Mobx world, root store pattern. I implement similar approach where I have a root machine that act as gateway for any machines that wants to work together.
These machines doesn't have to be a child machine, it is also standalone machine, but they can send event to each other and read their current state value inside guards, actions or services.
For more detail, please read here https://azamuddin.com/en/blog/240223-decouple-state-machine-without-parent-child-relationship
I'm just learning xstate and FSM in general for about a week, so there might be something that I missed that could make it even easier to achieve.
Comments, Suggestions, Feedback are appreciated.
Beta Was this translation helpful? Give feedback.
All reactions