Class HistoryEventPublisher<TEvent>
Represents a generic disposable event source that can be listened to, capable of recording previously published events.
public class HistoryEventPublisher<TEvent> : EventPublisher<TEvent>, IHistoryEventPublisher<TEvent>, IEventPublisher<TEvent>, IEventSource<TEvent>, IEventStream<TEvent>, IEventPublisher, IEventSource, IEventStream, IDisposable
Type Parameters
TEvent
Event type.
- Inheritance
-
EventSource<TEvent>EventPublisher<TEvent>HistoryEventPublisher<TEvent>
- Implements
-
IHistoryEventPublisher<TEvent>IEventPublisher<TEvent>IEventSource<TEvent>IEventStream<TEvent>
- Inherited Members
- Extension Methods
Constructors
HistoryEventPublisher(int)
Creates a new HistoryEventPublisher<TEvent> instance.
public HistoryEventPublisher(int capacity)
Parameters
capacity
intSpecifies the maximum number of events this event publisher can record.
Exceptions
- ArgumentOutOfRangeException
When
capacity
is less than 1.
Properties
Capacity
Specifies the maximum number of events this event publisher can record.
public int Capacity { get; }
Property Value
History
Collection of recorded previously published events.
public IReadOnlyCollection<TEvent> History { get; }
Property Value
- IReadOnlyCollection<TEvent>
Methods
ClearHistory()
Removes all recorded events.
public void ClearHistory()
OnDispose()
Allows to provide custom disposal implementation.
protected override void OnDispose()
OnPublish(TEvent)
Allows to react to event publishing.
protected override void OnPublish(TEvent @event)
Parameters
event
TEventEvent to publish.
OnSubscriberAdded(IEventSubscriber, IEventListener<TEvent>)
Allows to react to attachment of a new event subscriber.
protected override void OnSubscriberAdded(IEventSubscriber subscriber, IEventListener<TEvent> listener)
Parameters
subscriber
IEventSubscriberAttached event subscriber.
listener
IEventListener<TEvent>Event listener attached to the event subscriber.