Skip to main content

EventBus<T>

A class in Alta.EventBus.Runtime, Alta.EventBusSystem.

A simple in-process event bus for one event type T: listeners subscribe, and Send calls each one in order.

Constructors​

MemberWhat it is
EventBus()Creates an EventBus with default values.

Fields​

MemberWhat it is
const string DuplicateListenerLogPrefixText at the start of the error logged for a duplicate subscription.
2 private and internal fields
MemberWhat it is
private readonly List<Action<T>> listenersThe subscribed listeners.
private readonly Logger loggerNLog logger for this class.

Methods​

MemberWhat it is
void AddListener(Action<T> listener)Adds a listener. Adding the same delegate twice logs an error and is ignored.
void RemoveListener(Action<T> listener)Removes a listener if it is subscribed.
void Send(T eventObject)Calls every listener with the event object, in subscription order.

Used in​

Members of other types that take, return or hold a EventBus&lt;T>: