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
evtTEventThe event to publish.
ctCancellationTokenCancellation token to cancel the operation.
Returns
Type Parameters
TEventThe 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
evtTEventThe event to publish.
ctCancellationTokenCancellation token to cancel the operation.
Returns
Type Parameters
TEventThe 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
evtTEventThe event to publish.
ctCancellationTokenCancellation token to cancel the operation.
Type Parameters
TEventThe 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
evtTEventThe event to publish.
ctCancellationTokenCancellation token to cancel the operation.
Type Parameters
TEventThe 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
ownerobjectThe owner of the event bus, used for managing subscriptions.
handlerEventHandler<TEvent>Event handler to subscribe to the event bus.
handlerHashintOptional hash code for the handler, used to identify the subscription.
Returns
Type Parameters
TEventThe 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
ownerobjectOwner of the subscription, used for managing subscriptions.
handlerAction<TEvent>Handler function that processes the event.
Returns
- IDisposable
An IDisposable that can be used to unsubscribe from the event.
Type Parameters
TEventThe 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
ownerobjectOwner of the subscription, used for managing subscriptions.
handlerFunc<TEvent, ValueTask>Handler function that processes the event.
Returns
- IDisposable
An IDisposable that can be used to unsubscribe from the event.
Type Parameters
TEventThe type of the event to subscribe to.
Unsubscribe(object)
Unsubscribe all handlers for the given owner.
public static void Unsubscribe(object owner)
Parameters
ownerobjectOwner 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
ownerobjectOwner of the subscription, used for managing subscriptions.
handlerEventHandler<TEvent>Handler function that processes the event.
Type Parameters
TEventThe 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
ownerobjectOwner of the subscription, used for managing subscriptions.
handlerAction<TEvent>Handler function that processes the event.
Type Parameters
TEventThe type of the event to unsubscribe from.