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
exchange
IMutableEventExchangeSource event exchange.
Returns
- IEventPublisher<TEvent>
Registered IEventPublisher<TEvent> instance.
Type Parameters
TEvent
Event 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
exchange
IEventExchangeSource event exchange.
Returns
- IEventStream<TEvent>
Registered IEventStream<TEvent> instance.
Type Parameters
TEvent
Event 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
exchange
IEventExchangeSource event exchange.
Returns
- bool
true when event stream exists, otherwise false.
Type Parameters
TEvent
Event 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
exchange
IEventExchangeSource event exchange.
eventType
TypeEvent type.
listener
IEventListenerEvent 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
exchange
IEventExchangeSource event exchange.
listener
IEventListener<TEvent>Event listener to attach.
Returns
- IEventSubscriber
New IEventSubscriber instance that can be used to detach the
listener
.
Type Parameters
TEvent
Event 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
exchange
IMutableEventExchangeSource event exchange.
eventType
TypeEvent type.
event
objectEvent 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
exchange
IMutableEventExchangeSource event exchange.
event
TEventEvent to publish.
Type Parameters
TEvent
Event 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
exchange
IMutableEventExchangeSource event exchange.
Returns
- IEventPublisher<TEvent>
Registered event publisher.
Type Parameters
TEvent
Event 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
exchange
IMutableEventExchangeSource event exchange.
result
IEventPublisher<TEvent>out parameter that returns the registered IEventPublisher instance.
Returns
- bool
true when event publisher exists, otherwise false.
Type Parameters
TEvent
Event 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
exchange
IEventExchangeSource event exchange.
result
IEventStream<TEvent>out parameter that returns the registered IEventStream instance.
Returns
- bool
true when event stream exists, otherwise false.
Type Parameters
TEvent
Event 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
exchange
IEventExchangeSource event exchange.
eventType
TypeEvent type.
listener
IEventListenerEvent listener to attach.
subscriber
IEventSubscriberout 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
exchange
IEventExchangeSource event exchange.
listener
IEventListener<TEvent>Event listener to attach.
subscriber
IEventSubscriberout 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
TEvent
Event 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
exchange
IMutableEventExchangeSource event exchange.
eventType
TypeEvent type.
event
objectEvent 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
exchange
IMutableEventExchangeSource event exchange.
event
TEventEvent to publish.
Returns
- bool
true when event publisher exists, otherwise false.
Type Parameters
TEvent
Event type.