Communication between two unconnected machines #1379
Unanswered
Herdismaria
asked this question in
General
Replies: 1 comment
-
Can you create a CodeSandbox (XState template) with the current code that you have for this? There are potentially different ways to model this. You can still use an Actor model pattern where the API communication is set up in the parent ( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I'm relatively new to xState and I I am implementing a fairly complicated state machine in React.
A very short explanation: I have an ActiveTrips machine that can Add trips to it's context, end all trips and needs to poll a database for changes in the trips.
I then have a Trip machine that has Riding,Paused,Reserved,Ended states and can move between these. This machine also communicates with the server and ends and pauses trip.
I need a way for the Trip machine to communicate that it has ended to the ActiveTrips machine (and probably some other events).
I was going to use the Actor model for this but the useService hook does not take in config object like useMachine does and I need to send requests to our server and send different events based on the response and I don't know how to do this unless I get the send function from useMachine.
So if I move this apiCanParkCheck inside services in the machine I can't use the send function. I also have services that call functions from React.Contexts that I can't move into the Machine definition object.
Beta Was this translation helpful? Give feedback.
All reactions