Skip to content

Add entry and exit reactions to pystate#1

Open
TobiasPleyer wants to merge 1 commit intolwanger:masterfrom
TobiasPleyer:entry_and_exit_reactions
Open

Add entry and exit reactions to pystate#1
TobiasPleyer wants to merge 1 commit intolwanger:masterfrom
TobiasPleyer:entry_and_exit_reactions

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