public IDisposable CatchUpSubscription(long lastPosition, EventHandlerCallback onEvent, Action onHasCaughtUp) { if (StoreVersion() == -1) { hasCaughtUpHandler(true); } return(this.streamStore.SubscribeToAll(lastPosition, messageHandler, subscriptionDroppedHandler, hasCaughtUpHandler)); async Task messageHandler(IAllStreamSubscription subscription, StreamMessage streamMessage, CancellationToken cancellationToken) { var @event = await DeserializeEvent(streamMessage); onEvent(streamMessage.StreamId, streamMessage.Position, @event); } void subscriptionDroppedHandler(IAllStreamSubscription subscription, SubscriptionDroppedReason reason, Exception exception = null) { } void hasCaughtUpHandler(bool hasCaughtUp) { if (hasCaughtUp) { onHasCaughtUp(); } } }
public void Subscribe <T>(EventHandlerCallback handler) { if (!handlerList.ContainsKey(typeof(T))) { handlerList.Add(typeof(T), new List <dynamic>()); } handlerList[typeof(T)].Add(handler); }