Wait for state with always transition #5374
-
|
Hi! For state that have only Since Sandbox (open devtools console in browser to see logs): https://stackblitz.com/edit/vitejs-vite-fb8gt9ws?file=src%2Fmain.js |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
You can use the inspection API and listen for const actor = createActor(machine, {
inspect: (inspectionEv) => {
if (inspectionEv.type === '@xstate.microstep') {
// ... |
Beta Was this translation helpful? Give feedback.
-
|
@davidkpiano Hi! I just want to clarify - if there is no way to use the inspection api, it is not possible to track machine state with I should mention that only Using zero delay: const states = {
//...
"current target": {
after: {
0: "next target"
}
}
}
await waitFor(actor, (snapshot) => {
return snapshot.matches("current target");
});Using extra event just for delaying transition: const states = {
//...
"current target": {
on: {
"#intermediate proceed": "next target"
}
}
}
await waitFor(actor, (snapshot) => {
return snapshot.matches("current target");
});
actor.send({ type: "#intermediate proceed" }); |
Beta Was this translation helpful? Give feedback.
-
|
That's right - examining this is only currently possible through the inspection API. If you have access to the actor, you can inspect via |
Beta Was this translation helpful? Give feedback.
You can use the inspection API and listen for
@xstate.microstepinspection events: https://stately.ai/docs/inspection