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
TEventEvent 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
capacityintSpecifies the maximum number of events this event publisher can record.
Exceptions
- ArgumentOutOfRangeException
When
capacityis 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
eventTEventEvent 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
subscriberIEventSubscriberAttached event subscriber.
listenerIEventListener<TEvent>Event listener attached to the event subscriber.