ookami-kb / fsm

A library for finite state machine realization
https://pub.dev/packages/fsm/
BSD 2-Clause "Simplified" License
7 stars 1 forks source link

Improve onTransition to include prior state, new state and event. #3

Open bsutton opened 4 years ago

bsutton commented 4 years ago

To help with debugging I'm currently adding an onEnter and onExit method to each state.

It would be much nice if this could be done globally.

The GraphBuilder.onTransition listener seems an natural place to hook all transitions and log these events.

The problem is that the Transition object that the listener passes has little information that is of use.

Ideally the Transition object should contain:

Prior state New state Event SideEffect.

This would then allow it to be used for debug logging and reduce clutter in the state machine declaration.

ookami-kb commented 4 years ago

Yeah, makes sense. I'll take a look at it, thank you!