void onEvent(in Event e) { Eventdispatcher ed = new EventDispatcher(e); ed.dispatch!MyEvent(delegate void(MyEvent event) { event.toString().writeln; }); }
void onEvent(in Event e) { Eventdispatcher ed = new EventDispatcher(e); ed.dispatch!MyEvent((MyEvent event) { event.toString().writeln; }); }
auto func = (MyEvent event) { event.toString.writeln; }; void onEvent(in Event e) { Eventdispatcher ed = new EventDispatcher(e); ed.dispatch!MyEvent(func); }
void onMyEvent(MyEvent event) { event.toString.writeln; } void onEvent(in Event e) { import std.functional : toDelegate; Eventdispatcher ed = new EventDispatcher(e); ed.dispatch!MyEvent(toDelegate(&onMyEvent)); }
Dispatch an event
If the event variable in EventDispatcher is the same type as T calls func.