looplab / fsm

Finite State Machine for Go
Apache License 2.0
2.86k stars 312 forks source link

event handling but keeps in current state #111

Closed helioaymoto closed 2 months ago

helioaymoto commented 2 months ago

Hi Guys, I am quite new FSM, so I would like to see if someone can give a help. Basically, I would like to define an event, but this wouldn't change to new State. This event would keeps the state move to the same state. I can configure/program like this, but i couldn't make the callback work. I can use "enter_state", "leave_state" to define callback... but this does not run in case of an event which move to the same state. Do you know if there is some way to do this kind of behavior? Thanks in advance.

helioaymoto commented 2 months ago

Hi, I could find a solution for this. I could use "after_event" callback option, so I can create a function to identify this kind of transition where source and destination state are the same and trigger some specific Callback action. Kind regards.