Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Callback" feature for states #24

Open
kosist opened this issue Jan 14, 2021 · 1 comment
Open

"Callback" feature for states #24

kosist opened this issue Jan 14, 2021 · 1 comment

Comments

@kosist
Copy link

kosist commented Jan 14, 2021

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...

@Tom-McQuillan
Copy link
Collaborator

I like this idea, but the implementation would need to be a separate function to Parse State Queue (to prevent bloat).
A wrapper to Parse State Queue would do, or another function that appends an additional state next to PSQ.

The "Inbuilt way" would be to use Macros.

I will leave this issue open for now to see if this comment creates any traction in the idea. If not, I will close this issue in the upcoming weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants