Skip to content

FSM: fire onTransition() hooks for certain same-state transitions #13970

@viktorklang

Description

@viktorklang

imported from https://www.assembla.com/spaces/akka/tickets/3970

Currently, the FSM implementation does not fire onTransition() hooks when transitioning to the state the FSM is currently in.

It seems like there are use-cases for which a same-state transition is meaningful, and not merely indicative of a "no op" circumstance. For example, if one were implementing an FSM to simulate the handling of the regular expression _/(a)_b/*, the transition from state "a" back to itself is not a "no op" and it consumes one message to do so (the letter "a").

Furthermore it seems like Akka FSM's API would not need to be modified, as the user could make this distinction by choosing between goto(state) and stay() -- the first implying a transition and the second implying none.

I developed a FizzBuzz example that depends on a same-state transition, and works around the limitation using two identical states that simply bounce between each other. While workable it looks quite clumsy. https://gist.github.com/JavadocMD/9859519 It would be nice if Akka could support this without the need for ugly work-arounds.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues that the core team will likely not have time to work ont:core

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions