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

Add entry and exit reactions to pystate #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TobiasPleyer
Copy link

Entry and exit reactions are very useful if there are certain things
that have to be done every time we enter or leave a state (e.g.
cleanup). Instead of making sure that every handler performs the correct
tasks this will be handled by the function transition_to.

This is less error prone, more intuitive and saves key strokes.

Changes
* The State class has 4 new methods:
- add entry_reaction
- remove entry_reaction
- add exit_reaction
- remove exit_reaction
* In addition to changing the variable current_state the function
transition_to does:
- Call the exit reactions of the old state
- Call the entry reactions of the new state

Entry and exit reactions are very useful if there are certain things
that have to be done every time we enter or leave a state (e.g.
cleanup). Instead of making sure that every handler performs the correct
tasks this will be handled by the function `transition_to`.

This is less error prone, more intuitive and saves key strokes.

Changes
    * The State class has 4 new methods:
        - add entry_reaction
        - remove entry_reaction
        - add exit_reaction
        - remove exit_reaction
    * In addition to changing the variable current_state the function
      `transition_to` does:
        - Call the exit reactions of the old state
        - Call the entry reactions of the new 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

Successfully merging this pull request may close these issues.

1 participant