Skip to content

Calling dispatch() and/or transit() from action function #38

@MarioIvancic

Description

@MarioIvancic

In the comment for transit function there is a note: do not send events in action_function definisions.
As I understand, that limitation is bacause of order of operations inside transit() functions:

current_state_ptr->exit();
action_function();
current_state_ptr = &_state_instance<S>::value;
current_state_ptr->entry();

Any state change caused by action_function() will be overriden by the next line.

What if we rearrange operations so that action is last:

current_state_ptr->exit();
current_state_ptr = &_state_instance<S>::value;
current_state_ptr->entry();
action_function();

Now we can call all API functions without limitation. Any state change caused by action_function() will count as any other.
What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions