Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How To Fail A State Transition? #82

Open
billyb2 opened this issue Aug 20, 2024 · 1 comment
Open

How To Fail A State Transition? #82

billyb2 opened this issue Aug 20, 2024 · 1 comment

Comments

@billyb2
Copy link

billyb2 commented Aug 20, 2024

Hi! While working with this library, I noticed that it isn't really possible to fail a state transition. If a state's OnEntry or OnExit return an error, it looks like the state of the FSM is still updated. Is there a way to automatically set the state back to how it previously was, if the transition fails? I of course could do that by having another trigger, but having that happen automatically could be useful.

Thank you for this amazing library :)

@daniel-sullivan
Copy link

An interesting thing I've just discovered while going through the code and considering writing my own implementation is that the problem you'll always get is that the OnExit of the previous state has already been called so you'd have to re-enter it. I also noticed though that returning an error on OnExit will stop the state from transitioning.

In our case, we can put the bootstrap code for the next state in the OnExit of the previous state (very simple enabled / disabled flow)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants