Skip to content

Invoke machine in another machine but also standalone, with resetting #1620

Answered by f-elix
sederaa asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

I think there are a few solutions to this, depending on your precise use case. I can think of 2 right now:

  1. You don't use machine A as a standalone machine, instead you can invoke it on machine B and forward the events from B (parent) to A (child). This will allow you to communicate a 'DONE' event from machine A with the sendParent() action (https://xstate.js.org/docs/guides/communication.html#invoking-machines) when entering state2, instead of having the state be final. You can then send a 'Reset' event to machine B, which will forward it to machine A.

  2. You reverse the roles and instead invoke machine B from machine A, and communicate your result to machine B by using the send() ac…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by sederaa
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants