Class EventBridge
Also see EventBridge
public static class EventBridge
- Inheritance
-
EventBridge
- Inherited Members
Methods
Dispose()
Publish an event synchronously to all subscribers, with error handling.
public static void Dispose()
PublishAsync<TEvent>(TEvent, CancellationToken)
Publish an event asynchronously to all subscribers.
public static ValueTask PublishAsync<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent
Parameters
evt
TEventThe event to publish.
ct
CancellationTokenCancellation token to cancel the operation.
Returns
Type Parameters
TEvent
The type of the event to publish.
PublishSafeAsync<TEvent>(TEvent, CancellationToken)
Publish an event asynchronously to all subscribers, with error handling.
public static ValueTask PublishSafeAsync<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent
Parameters
evt
TEventThe event to publish.
ct
CancellationTokenCancellation token to cancel the operation.
Returns
Type Parameters
TEvent
The type of the event to publish.
PublishSafe<TEvent>(TEvent, CancellationToken)
Publish an event synchronously to all subscribers, with error handling.
public static void PublishSafe<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent
Parameters
evt
TEventThe event to publish.
ct
CancellationTokenCancellation token to cancel the operation.
Type Parameters
TEvent
The type of the event to publish.
Publish<TEvent>(TEvent, CancellationToken)
Publish an event synchronously to all subscribers.
public static void Publish<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent
Parameters
evt
TEventThe event to publish.
ct
CancellationTokenCancellation token to cancel the operation.
Type Parameters
TEvent
The type of the event to publish.
Subscribe<TEvent>(object, EventHandler<TEvent>, int)
Initializes a new instance of the ManagedEventBus class.
public static IDisposable Subscribe<TEvent>(object owner, EventHandler<TEvent> handler, int handlerHash = 0) where TEvent : IEvent
Parameters
owner
objectThe owner of the event bus, used for managing subscriptions.
handler
EventHandler<TEvent>Event handler to subscribe to the event bus.
handlerHash
intOptional hash code for the handler, used to identify the subscription.
Returns
Type Parameters
TEvent
The type of the event to subscribe to.
Subscribe<TEvent>(object, Action<TEvent>)
Subscribe a handler and receive an IDisposable that will unsubscribe when disposed.
public static IDisposable Subscribe<TEvent>(object owner, Action<TEvent> handler) where TEvent : IEvent
Parameters
owner
objectOwner of the subscription, used for managing subscriptions.
handler
Action<TEvent>Handler function that processes the event.
Returns
- IDisposable
An IDisposable that can be used to unsubscribe from the event.
Type Parameters
TEvent
The type of the event to subscribe to.
Subscribe<TEvent>(object, Func<TEvent, ValueTask>)
Subscribe a handler and receive an IDisposable that will unsubscribe when disposed.
public static IDisposable Subscribe<TEvent>(object owner, Func<TEvent, ValueTask> handler) where TEvent : IEvent
Parameters
owner
objectOwner of the subscription, used for managing subscriptions.
handler
Func<TEvent, ValueTask>Handler function that processes the event.
Returns
- IDisposable
An IDisposable that can be used to unsubscribe from the event.
Type Parameters
TEvent
The type of the event to subscribe to.
Unsubscribe(object)
Unsubscribe all handlers for the given owner.
public static void Unsubscribe(object owner)
Parameters
owner
objectOwner of the subscriptions to unsubscribe.
Unsubscribe<TEvent>(object, EventHandler<TEvent>)
Unsubscribe a handler from the event bus.
public static void Unsubscribe<TEvent>(object owner, EventHandler<TEvent> handler) where TEvent : IEvent
Parameters
owner
objectOwner of the subscription, used for managing subscriptions.
handler
EventHandler<TEvent>Handler function that processes the event.
Type Parameters
TEvent
The type of the event to unsubscribe from.
Unsubscribe<TEvent>(object, Action<TEvent>)
Unsubscribe a handler from the event bus.
public static void Unsubscribe<TEvent>(object owner, Action<TEvent> handler) where TEvent : IEvent
Parameters
owner
objectOwner of the subscription, used for managing subscriptions.
handler
Action<TEvent>Handler function that processes the event.
Type Parameters
TEvent
The type of the event to unsubscribe from.