Table of Contents

Interface IImmutableProjectionHandler<TProjection, TEvent>

Namespace
Excalibur.EventSourcing
Assembly
Excalibur.EventSourcing.Abstractions.dll

Defines a typed, DI-resolved event handler for immutable projection transforms.

public interface IImmutableProjectionHandler<TProjection, in TEvent> where TProjection : class where TEvent : IDomainEvent

Type Parameters

TProjection

The immutable projection state type (e.g., a C# record).

TEvent

The domain event type this handler processes.

Remarks

Unlike IProjectionEventHandler<TProjection, TEvent> which mutates state in-place, this handler returns a new projection instance (functional transform pattern).

The current parameter on TransformAsync(TProjection?, TEvent, ProjectionHandlerContext, CancellationToken) is null when this is the first event for a projection ID. Handlers should create a new instance (factory) or throw depending on their semantics.

Methods

TransformAsync(TProjection?, TEvent, ProjectionHandlerContext, CancellationToken)

Transforms the projection state by producing a new instance from the current state and the event.

Task<TProjection> TransformAsync(TProjection? current, TEvent @event, ProjectionHandlerContext context, CancellationToken cancellationToken)

Parameters

current TProjection

The current projection state, or null if no projection exists for this ID yet (creation scenario).

event TEvent

The domain event to process.

context ProjectionHandlerContext

Context providing aggregate metadata and optional projection ID override.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TProjection>

A new projection instance representing the updated state.