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

Wrong order of events in state-machine code #499

Open
igittigitt opened this issue Jan 20, 2024 · 1 comment
Open

Wrong order of events in state-machine code #499

igittigitt opened this issue Jan 20, 2024 · 1 comment

Comments

@igittigitt
Copy link

igittigitt commented Jan 20, 2024

In your very finde article about state-machines
https://kentcdodds.com/blog/implementing-a-simple-state-machine-library-in-javascript
you put the onExit() and onEnter() events after the action() event:

destinationTransition.action()
currentStateDefinition.actions.onExit()
destinationStateDefinition.actions.onEnter()

Maybe i did not get the principles right, but wouldn't this order be the right one?

currentStateDefinition.actions.onExit()
destinationTransition.action()
destinationStateDefinition.actions.onEnter()
@kentcdodds
Copy link
Owner

I'm not positive, it was a long time ago that I wrote this blog post. But if you can link me to the part in the specification that says I'm wrong, then I'm happy to correct it!

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