import type { Constructor } from '@cratis/fundamentals'; import type { BatchContext } from '../observation/batches/BatchContext.js'; import type { BatchMethod } from '../observation/batches/BatchMethod.js'; import type { EventBatch } from '../observation/batches/EventBatch.js'; import type { EventContext } from '../events/EventContext.js'; import type { ReducerEventHandler } from './ReducerEventHandler.js'; /** Selects and invokes the same reducer handlers for kernel deliveries and in-process scenarios. */ export declare class ReducerEventDispatcher { /** The per-event handlers; empty when the reducer has a batch method. */ readonly handlers: ReducerEventHandler[]; /** The batch method, when the reducer has one instead of per-event handlers. */ readonly batchMethod: BatchMethod | undefined; readonly validateInstance: (instance: object) => void; /** * Discovers event methods from the artifact event types. A reducer has either per-event methods or one batch method. * @param reducerType - The reducer class. * @param eventTypes - The event types registered with the event store. * @throws {@link ReducerMixesBatchAndPerEventMethods} when the reducer mixes batch and per-event methods, or has two batch methods. */ constructor(reducerType: Constructor, eventTypes: readonly Constructor[]); /** The event types the reducer registers: the batch method's observed types, or the per-event handlers' types. */ get eventTypes(): readonly { readonly id: string; readonly generation: number; }[]; /** Resolves a registered event type, or returns undefined for an unsubscribed event. */ handlerFor(eventTypeId: string): ReducerEventHandler | undefined; /** Calls the selected handler with the event, current state, and context. */ invoke(instance: Record, handler: ReducerEventHandler, event: unknown, currentState: unknown, context: EventContext): Promise; /** * Calls the batch method with the events of one event source, its current state and the page's context. * @param instance - The reducer instance. * @param batch - The {@link EventBatch} of the event source. * @param currentState - The stored state of the event source, or undefined. * @param context - The {@link BatchContext} of the page. * @returns The next state; undefined or null removes the read model. */ invokeBatch(instance: Record, batch: EventBatch, currentState: unknown, context: BatchContext): Promise; } //# sourceMappingURL=ReducerEventDispatcher.d.ts.map