public void SubscribeToEvent <TEvent>(EventReceivedAsync <TEvent> eventReceived) where TEvent : class, IEvent { _engine.SubscribeToEvent <TEvent>(); _errorHandlers.AddOrUpdate(typeof(TEvent), CreateEventErrorDelegate <TEvent>(), (key, item) => item); _messagePipelines.Add(async message => { if (message is EventMessage <TEvent> eventMessage) { var dispatcher = new NybusDispatcher(this, eventMessage); var context = new NybusEventContext <TEvent>(eventMessage); await eventReceived(dispatcher, context).ConfigureAwait(false); } }); }
public void SubscribeToEvent <TEvent>() where TEvent : class, IEvent { _busEngine.SubscribeToEvent((EventReceived <TEvent>)ResolveHandlerAndHandle <IEventHandler <TEvent>, TEvent>); }