If I want to create a generic class that can store and call functions of some specific (but generic) type, what would be the best way to achieve that in Haxe in a typesafe way?
e.g.
var onSpawn: Dispatcher<>;
var onKill: Dispatcher<Unit>;
var onDeath: Dispatcher<Unit>;
var onDealDamage: Dispatcher<Int, DamageType, Unit>;
...
onDealDamange.register(some_function_or_delegate, order);
onDealDamange.register(another_function_or_delegate, order);
...
onDealDamage.call(20, Physical, aUnit);
I would like to implement Dispatcher, such that I don’t have to introduce any new types manually whenever I have a new dispatcher (with new type parameters).