Interface IProjectionEventHandler<TProjection, TEvent>
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Defines a typed, DI-resolved event handler for projection updates.
public interface IProjectionEventHandler<TProjection, in TEvent> where TProjection : class, new() where TEvent : IDomainEvent
Type Parameters
TProjectionThe projection state type.
TEventThe domain event type this handler processes.
Remarks
Implement this interface for projection logic that requires dependency injection,
async operations, or custom projection ID targeting. Register via
WhenHandledBy<TEvent, THandler>() on the projection builder.
For simple synchronous projections, prefer When<TEvent> lambdas instead.
Methods
HandleAsync(TProjection, TEvent, ProjectionHandlerContext, CancellationToken)
Applies the event to the projection state.
Task HandleAsync(TProjection projection, TEvent @event, ProjectionHandlerContext context, CancellationToken cancellationToken)
Parameters
projectionTProjectionThe projection instance to update.
eventTEventThe domain event to process.
contextProjectionHandlerContextContext providing aggregate metadata and optional projection ID override. Set OverrideProjectionId to target a different projection instance than the default (aggregate ID).
cancellationTokenCancellationTokenCancellation token.
Returns
- Task
A task representing the asynchronous operation.