Skip to content

v5 - How can I invoke another machine from one machine? #4886

Answered by with-heart
DWboutin asked this question in General
Discussion options

You must be logged in to vote

Hi @DWboutin!

Can you help me on how I can do something like this?

Here's an example of how to achieve what you're trying to do: https://codesandbox.io/p/devbox/zealous-goldberg-l9rc5c?file=/src/main.ts (make sure to open devtools console to see the output)

In place of data on the final state, we can define an output type in setup and then use the top-level output property which is then available on event.output.

can I use a machine to set the initial context of another machine?

Sure can! https://codesandbox.io/p/devbox/async-glitter-dh6npw?file=/src/main.ts

We can define the type of input in setup, use that input to set the initial context, and then define the input in invoke.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DWboutin
Comment options

Answer selected by DWboutin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants