-
I'm signaling If The following is what I came up with, but I am unsure if this is the best way: services: {
moveItem: (ctx) => new Promise<void>((resolve, reject) => {
ctx.otherMachine.send({type: "MOVE", data: {item: ctx.item}})
waitFor(ctx.otherMachine, (state) => {
if (state.matches('Moving.Failure')) reject(new Error('Move failed unrecoverably'))
return state.matches('Ready')
}, {timeout: 60000}).then(() => resolve())
})
} I also tried throwing in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Waiting for both states that you are interested in ( |
Beta Was this translation helpful? Give feedback.
Waiting for both states that you are interested in (
'Ready'
and'Moving.Failure'
) sounds like a very good solution if you want to stick withwaitFor
. Alternatively, in v5 you will be able to sendself
together with your'MOVE'
event and the recipient should be able to "respond" later directly to your "requester" - so you wouldn't even need to usewaitFor
. YMMV though.