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 refer to data in state transition functions #197

Open
cayblood opened this issue May 19, 2020 · 1 comment
Open

how to refer to data in state transition functions #197

cayblood opened this issue May 19, 2020 · 1 comment

Comments

@cayblood
Copy link

cayblood commented May 19, 2020

I would like to be able to prevent certain transitions by adding logic to check the data attribute in onBeforeTransition. It's not immediately clear how best to update the code to support this. Thanks in advance for any help you can provide.

@musicin3d
Copy link

musicin3d commented Apr 16, 2021

Hi there. I was just wandering by, and I saw your comment. Hopefully, you found a solution by now, but someone else might have the same question.

Unless I'm mistaken, that breaks the rules of finite state machines. You might need a more complex model. You could create a class or pure object with all the methods, state, and rules; or you could add more states to your machine to cover all the cases.

Edit:
It looks like you might also be able to accomplish something like this with "conditional transitions." If the data doesn't look good, you can redirect to a different state.

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