feat: add reducer factory method

This commit is contained in:
2025-08-11 13:52:29 +02:00
parent cc8c558db6
commit 91c3755533
2 changed files with 40 additions and 14 deletions

View File

@@ -184,6 +184,17 @@ export class EventStore<TEventFactory extends EventFactory, TEventStoreAdapter e
): InstanceType<TAggregate> => {
return aggregate.from(this, snapshot);
},
/**
* Create a new reducer instance for the given aggregate.
*
* @param aggregate - Aggregate to create a reducer for.
*/
reducer: <TAggregate extends AggregateRootClass<TEventFactory>>(
aggregate: TAggregate,
): Reducer<TEventFactory, InstanceType<TAggregate>> => {
return makeAggregateReducer(this, aggregate);
},
};
/*