Replies: 1 comment
-
Hey, sorry for the late reply! The new pattern in v5 is to use a wildcard transition to catch any events that do not lead to any other defined transitions. But for your use-case, you can just check state equality: // assume snapshot exists
const nextSnapshot = getNextSnapshot(machine, snapshot, event);
// nothing happened
if (nextSnapshot === snapshot) {
// return 304/409 etc.
} Let me know if this points you in the right direction. |
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
-
Hello guys,
I'm testing XState (I really love the concept of the this lib, great work!) integration in an application with a Rest API and I'd like to be able to return the correct http code based on what the person is trying to do on a state machine. I get the impression that this looks like the strict mode that used to exist.
In my tests XState doesn't tell me that a transition is impossible or that I'm already in the requested state. The machine simply stays in its current state.
For example, if someone tries to transition a state machine to the state it's already in, I'd like to return an HTTP code 304. Or if someone tried to go to an impossible state that I could return a 409 code.
I have a feeling I could use
actor.subscribe
but I haven't figured out how to do it.Beta Was this translation helpful? Give feedback.
All reactions