Interface IEventHandler<TEvent>
- Namespace
- Signal.Application.Events
- Assembly
- Signal.Application.dll
Handles a domain event. Any number of handlers may exist per event type; they are resolved from the message's DI scope and run sequentially in registration order.
public interface IEventHandler<in TEvent> where TEvent : IDomainEvent
Type Parameters
TEventThe handled event type, e.g. MessageReceived.
Examples
public sealed class Audit(ILogger<Audit> log) : IEventHandler<GroupUpdated>
{
public Task HandleAsync(GroupUpdated e, CancellationToken ct)
{
log.LogInformation("Group {Group} changed", e.Group);
return Task.CompletedTask;
}
}
Methods
HandleAsync(TEvent, CancellationToken)
Handles the event.
Task HandleAsync(TEvent domainEvent, CancellationToken cancellationToken)
Parameters
domainEventTEventThe event.
cancellationTokenCancellationTokenCancelled when the host shuts down.
Returns
- Task
A task that completes when the event was handled.