Table of Contents

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

TProjection

The projection state type.

TEvent

The 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

projection TProjection

The projection instance to update.

event TEvent

The domain event to process.

context ProjectionHandlerContext

Context providing aggregate metadata and optional projection ID override. Set OverrideProjectionId to target a different projection instance than the default (aggregate ID).

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task representing the asynchronous operation.