Skip to content

Commit

Permalink
allow passing of custom implementation EventStore.appendToStream opti…
Browse files Browse the repository at this point in the history
…ons to CommandHandler handle
  • Loading branch information
alex-laycalvert authored and oskardudycz committed May 17, 2024
1 parent 1f8db48 commit 3feae3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/packages/emmett/src/commandHandling/handleCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const CommandHandler =
getInitialState: () => State,
mapToStreamId: (id: string) => string = (id) => id,
) =>
async (
eventStore: EventStore<StreamVersion>,
async <Store extends EventStore<StreamVersion>>(
eventStore: Store,
id: string,
handle: (state: State) => StreamEvent | StreamEvent[],
options?: {
options?: Parameters<Store['appendToStream']>[2] & {
expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
},
): Promise<CommandHandlerResult<State, StreamVersion>> => {
Expand Down Expand Up @@ -68,6 +68,7 @@ export const CommandHandler =
streamName,
newEvents,
{
...options,
expectedStreamVersion,
},
);
Expand Down

0 comments on commit 3feae3f

Please sign in to comment.