associateBaseEvent<TSuper extends TBase, TBase extends IEvent> method

void associateBaseEvent<TSuper extends TBase, TBase extends IEvent>()

Associates a specific Type with it's base Type.

This can also be done for implemented interfaces rather than just for extended classes. Multiple assocations for a type are allowed (such as if you used interfaces). Base event subscribers will always be called after the derived ones.

mediator.associateBaseEvent<MyDerivedEvent, MyBaseEvent>();

Implementation

void associateBaseEvent<TSuper extends TBase, TBase extends IEvent>() {
  List<Type>? associations = _baseEventAssociations[TSuper];
  if (associations == null) {
    associations = [];
    _baseEventAssociations[TSuper] = associations;
  }

  if (associations.contains(TBase) == false) associations.add(TBase);
}