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

introduce EnterStatePolicy #4

Open
pierremrtn opened this issue Dec 30, 2023 · 0 comments
Open

introduce EnterStatePolicy #4

pierremrtn opened this issue Dec 30, 2023 · 0 comments

Comments

@pierremrtn
Copy link

pierremrtn commented Dec 30, 2023

Introduce ReEnterStatePolicy object that lets users control state re-entering conditions:

enum ReEnterStatePolicy {
    always,
    notIdentical,
    notEqual,
    never,
}

This allows users to control whether the machine considers a transition from the same state as a new transition or not (and re-triggering onEnter / onExit callbacks).

  • always: Always enter the state when a transition returns the state, regardless of whether the current state is already the same. This allows for mutable states.

  • notIdentical: Enter the state when a transition returns the state and if the current state is not identical to the new state (using identical for comparison).

  • notEqual: Enter the state when a transition returns the state and if the current state is not equal to the new state (using the == operator).

  • never: Prevent re-entering the state if a transition returns the same state as the current one. This allows for disabling the re-trigger of parent state onEnter / onExit callbacks.

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

1 participant