Replies: 2 comments 2 replies
-
@Andarist @davidkpiano @mattpocock |
Beta Was this translation helpful? Give feedback.
-
@Andarist @davidkpiano exampleAction: enqueueActions(({ context, enqueue, check }) => {
const user = context.users.find((user) => user.name === 'xstate')
if (check({ type: 'exampleGuard', params: { user } })) {
// ...
}
})
// ...
states: {
IDLE: {
on: {
MAKE_SOMETHING: {
actions: 'exampleAction' // stop transition to target if check inside is false
target: 'nextstate'
}
}
}
} On the one hand, it would be logical that since we use “check” with the defender, the further logic of the state transition would stop. But then this would mean that we now have actions that can stop the transition as well as protectors. What do you think? |
Beta Was this translation helpful? Give feedback.
-
For example, I have a code like this:
The code above is perfect for me, since I already have a codebase and am porting the code to xstate. I have complex calculations in actions that will either execute or not, let's say it's random.
But, in the case of “throw new Error()”, I will get a stopped actor that is no longer running. And that's terrible!
Ok, I've read your documentation and realized that you want actors in general to prevent such situations, that it would be solved at guard level, but:
The 2nd point is especially important, and it's quite critical, especially since my case study involves a server application, not a client application.
Question: is there anything else I may have missed by studying your library that will help me with my situation? Thank you
Beta Was this translation helpful? Give feedback.
All reactions