Class EventExchangeExtensions
- Namespace
- LfrlAnvil.Reactive.Extensions
- Assembly
- LfrlAnvil.Reactive.Core.dll
Contains IEventExchange extension methods.
public static class EventExchangeExtensions
- Inheritance
-
EventExchangeExtensions
- Inherited Members
Methods
GetPublisher<TEvent>(IMutableEventExchange)
Returns an event publisher associated with the provided event type.
[Pure]
public static IEventPublisher<TEvent> GetPublisher<TEvent>(this IMutableEventExchange exchange)
Parameters
exchangeIMutableEventExchangeSource event exchange.
Returns
- IEventPublisher<TEvent>
Registered IEventPublisher<TEvent> instance.
Type Parameters
TEventEvent type to check.
Exceptions
- EventPublisherNotFoundException
When event publisher does not exist.
GetStream<TEvent>(IEventExchange)
Returns an event stream associated with the provided event type.
[Pure]
public static IEventStream<TEvent> GetStream<TEvent>(this IEventExchange exchange)
Parameters
exchangeIEventExchangeSource event exchange.
Returns
- IEventStream<TEvent>
Registered IEventStream<TEvent> instance.
Type Parameters
TEventEvent type to check.
Exceptions
- EventPublisherNotFoundException
When event stream does not exist.
IsRegistered<TEvent>(IEventExchange)
Checks whether or not an event stream for the provided event type exists.
[Pure]
public static bool IsRegistered<TEvent>(this IEventExchange exchange)
Parameters
exchangeIEventExchangeSource event exchange.
Returns
- bool
true when event stream exists, otherwise false.
Type Parameters
TEventEvent type to check.
Listen(IEventExchange, Type, IEventListener)
Attaches the provided listener to an event stream associated with the specified eventType.
public static IEventSubscriber Listen(this IEventExchange exchange, Type eventType, IEventListener listener)
Parameters
exchangeIEventExchangeSource event exchange.
eventTypeTypeEvent type.
listenerIEventListenerEvent listener to attach.
Returns
- IEventSubscriber
New IEventSubscriber instance that can be used to detach the
listener.
Exceptions
- EventPublisherNotFoundException
When event stream does not exist.
Listen<TEvent>(IEventExchange, IEventListener<TEvent>)
Attaches the provided listener to an event stream associated with the specified event type.
public static IEventSubscriber Listen<TEvent>(this IEventExchange exchange, IEventListener<TEvent> listener)
Parameters
exchangeIEventExchangeSource event exchange.
listenerIEventListener<TEvent>Event listener to attach.
Returns
- IEventSubscriber
New IEventSubscriber instance that can be used to detach the
listener.
Type Parameters
TEventEvent type.
Exceptions
- EventPublisherNotFoundException
When event stream does not exist.
Publish(IMutableEventExchange, Type, object?)
Publishes an event on an event publisher associated with the specified eventType.
public static void Publish(this IMutableEventExchange exchange, Type eventType, object? @event)
Parameters
exchangeIMutableEventExchangeSource event exchange.
eventTypeTypeEvent type.
eventobjectEvent to publish.
Exceptions
- EventPublisherNotFoundException
When event publisher does not exist.
Publish<TEvent>(IMutableEventExchange, TEvent)
Publishes an event on an event publisher associated with the specified event type.
public static void Publish<TEvent>(this IMutableEventExchange exchange, TEvent @event)
Parameters
exchangeIMutableEventExchangeSource event exchange.
eventTEventEvent to publish.
Type Parameters
TEventEvent type.
Exceptions
- EventPublisherNotFoundException
When event publisher does not exist.
RegisterPublisher<TEvent>(IMutableEventExchange)
Creates a new EventPublisher<TEvent> instance and registers it.
public static IEventPublisher<TEvent> RegisterPublisher<TEvent>(this IMutableEventExchange exchange)
Parameters
exchangeIMutableEventExchangeSource event exchange.
Returns
- IEventPublisher<TEvent>
Registered event publisher.
Type Parameters
TEventEvent type.
Exceptions
- EventPublisherAlreadyExistsException
When event publisher for the given event type already exists.
TryGetPublisher<TEvent>(IMutableEventExchange, out IEventPublisher<TEvent>)
Attempts to return an event publisher associated with the provided event type.
public static bool TryGetPublisher<TEvent>(this IMutableEventExchange exchange, out IEventPublisher<TEvent> result)
Parameters
exchangeIMutableEventExchangeSource event exchange.
resultIEventPublisher<TEvent>out parameter that returns the registered IEventPublisher instance.
Returns
- bool
true when event publisher exists, otherwise false.
Type Parameters
TEventEvent type to check.
TryGetStream<TEvent>(IEventExchange, out IEventStream<TEvent>)
Attempts to return an event stream associated with the provided event type.
public static bool TryGetStream<TEvent>(this IEventExchange exchange, out IEventStream<TEvent> result)
Parameters
exchangeIEventExchangeSource event exchange.
resultIEventStream<TEvent>out parameter that returns the registered IEventStream instance.
Returns
- bool
true when event stream exists, otherwise false.
Type Parameters
TEventEvent type to check.
TryListen(IEventExchange, Type, IEventListener, out IEventSubscriber)
Attempts to attach the provided listener to an event stream associated
with the specified eventType.
public static bool TryListen(this IEventExchange exchange, Type eventType, IEventListener listener, out IEventSubscriber subscriber)
Parameters
exchangeIEventExchangeSource event exchange.
eventTypeTypeEvent type.
listenerIEventListenerEvent listener to attach.
subscriberIEventSubscriberout parameter that returns the new IEventSubscriber instance that can be used to detach the
listener.
Returns
- bool
true when event stream exists, otherwise false.
TryListen<TEvent>(IEventExchange, IEventListener<TEvent>, out IEventSubscriber)
Attempts to attach the provided listener to an event stream associated with the specified event type.
public static bool TryListen<TEvent>(this IEventExchange exchange, IEventListener<TEvent> listener, out IEventSubscriber subscriber)
Parameters
exchangeIEventExchangeSource event exchange.
listenerIEventListener<TEvent>Event listener to attach.
subscriberIEventSubscriberout parameter that returns the new IEventSubscriber instance that can be used to detach the
listener.
Returns
- bool
true when event stream exists, otherwise false.
Type Parameters
TEventEvent type.
TryPublish(IMutableEventExchange, Type, object?)
Attempts to publish an event on an event publisher associated with the specified eventType.
public static bool TryPublish(this IMutableEventExchange exchange, Type eventType, object? @event)
Parameters
exchangeIMutableEventExchangeSource event exchange.
eventTypeTypeEvent type.
eventobjectEvent to publish.
Returns
- bool
true when event publisher exists, otherwise false.
TryPublish<TEvent>(IMutableEventExchange, TEvent)
Attempts to publish an event on an event publisher associated with the specified event type.
public static bool TryPublish<TEvent>(this IMutableEventExchange exchange, TEvent @event)
Parameters
exchangeIMutableEventExchangeSource event exchange.
eventTEventEvent to publish.
Returns
- bool
true when event publisher exists, otherwise false.
Type Parameters
TEventEvent type.