On events, dispatchers and lists (a general explanation of the system)
The system works with the following classes and interfaces:
This is how events are exposed to the ourside world
IEvent<TSender, TArgs>– models an event with a generic sender and generic argument.
ISimpleEvent<TArgs>– models a simple event with a generic argument.
ISignal– models a signal; an argumentless event.
ISubscribable<THandlerType>– Base interface for the events. Not used outside the system. Helps to make an abstraction over events by making the handler of an event generic. Needed for the system to use base class implementations.
This is how the the outside world subscribes to an event. It defines the function signature.
(sender: TSender, args: TArgs): void– this handler is for events.
(args: TArgs): void– this handler is for simple events.
(): void– this handler is for signals.
This is how events are implemented. It implements a
unsubscribeand provides a
dispatchmethod for dispatching the events. Dispatchers make the whole system work.
EventDispatcher<TSender, TArgs>– implements a dispatcher for events.
SimpleEventDispatcher<TArgs>– implements a dispatcher for simple events.
SignalDispatcher– implements a dispatcher for signals.
DispatcherBase<TEventHandler>– abstract base class to implement dispatchers.
Helps with the implementation of multiple named events. Events are automatically created when a
getis called. Useful when implementing multiple events on a class.
EventList<TSender, TArgs>– implements an event list for events.
SimpleEventList<TArgs>– implements an event list for simple events.
SignalList– implements an event list for signals.
EventListBase<TEventDispatcher>– abstract base class for event lists.