Events double dispatching support
nameofuser1 opened this issue · 3 comments
What do you think about making Events to be double dispatch-able? For now it is necessary to explicitly specify event type when dispatching event, however since it is c++ library it can be useful to take advantage of polymorphic events.
TinyFSM does not limit Fsm::dispatch()
to any type, this simply calls State::react()
of the current state with the given type (which does not necessarily needs to be derived from tinyfsm::Event
).
I'm not sure what you mean by "double dispatchable", maybe you can elaborate this with a short example?
I meant simple visitor patter.
Imagine class hierarchy:
tinyfsm::Event
|
_________|_________
| |
Event1 Event2
Right now is not possible to dispatch Event1 by passing pointer to tinyfsm::Event into dispatch function.
This issue visitor pattern can solve.
I met the necessity of this feature when was trying to pass events via queue to another thread and actually this can be a common approach in embedded systems. However after an event is extracted from the queue its' actual type is unknown and for now it is required to explicitly determine event type.
But as you said react
function is not binded to tinyfsm::Event, and now I see that visitor is not applicable here )
answered, added "wontfix" label (as there is nothing to fix ;-)