Replies: 1 comment
-
This is how you would do that: const someMachine = createMachine({
// ...
invoke: {
src: promiseLogic,
input: ({ self }) => ({ parent: self })
}
});
const promiseLogic = fromPromise(({ input }: {
input: { parent: ActorRefFrom<typeof someLogic> }
}) => {
// ...
input.parent.send({/* ... */}); // Should be strongly-typed
// ...
}) |
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
-
Sending back from a callback actor is really straightforward - a nicely typed
sendBack
function is provided for you by XState and you're good to go. It's not clear to me exactly what the process is for sending back with a promise actor. As far as I can tell the way you would do this is by getting the parent and then calling send on it. For example:Managing ids and a loss of typesafety doesn't seem right for such a basic task, especially since similar tasks have a clean API for it. What am I missing? Looking at the docs the only thing I see is a mention about passing in a reference to the parent using the input, but its not clear to me how one would do that.
Any help would be appreciated. Thanks
Beta Was this translation helpful? Give feedback.
All reactions