JKI-State-Machine icon indicating copy to clipboard operation
JKI-State-Machine copied to clipboard

"Callback" feature for states

Open kosist opened this issue 4 years ago • 1 comments

Maybe it could break somehow concept of State Machine, but the idea is the following.

Sometimes there is need to define repeating transitions from one state to another. For example, there is state "Log message", and it should be executed after some selected 10 states. So now it is needed to implement this transition in each of those states.

But, what if there would be possible to define somehow callback for the states (maybe "callback" is not exactly proper term)? Something like: State A -> Log message State B -> Log message, etc. - so then there will be no need to add "Add State(s) to Queue" function to each of the states, and string constant with the state.

This could be part of "Parse State Queue" function (additional input), because it controls states transitions and thus there could be done some kind of hook for those "callbacks". But on the other hand that could influence on performance of the function (if it will need to parse strings all the time...

kosist avatar Jan 14 '21 14:01 kosist