-
Notifications
You must be signed in to change notification settings - Fork 1
Creating EventBroker
EventBroker constructor takes an IEventHandlerRunner instance and optional IEventHandlerFactory instance.
public EventBroker(IEventHandlerRunner runner, IEventHandlerFactory handlersFactory = null)
IEventHandlerRunner implements the execution of event handlers.
When event is published EventBroker resolves all event handlers using subscriptions and invoking the IEventHandlerFactory, packs them as actions and passes them to the IEventHandlerRunner for execution.
From publisher's point of view publishing is completed and it can move on with it's own business.
IEventHandlerRunner takes over the execution of event handlers passed to it.
Application can use multiple event brokers with different strategies for executing event handlers depending on it's needs.
IEventHandlerFactory.HandlersFor<TEvent>() is invoked every time event of type TEvent is published. This allows for Inversion of Control container to be used for resolving event handlers.