Skip to content

Commit

Permalink
feat: await beforeCommit, onCommitted
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfromundefined committed Apr 15, 2024
1 parent a8ae5ca commit ad05bce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/eventive/src/EventivePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ export type EventivePlugin<
DomainEvent extends BaseDomainEvent<string, {}>,
State extends {}
> = {
beforeCommit?(args: { event: DomainEvent; entity: BaseEntity<State> }): void;
onCommitted?(args: { event: DomainEvent; entity: BaseEntity<State> }): void;
beforeCommit?(args: {
event: DomainEvent;
entity: BaseEntity<State>;
}): void | Promise<void>;
onCommitted?(args: {
event: DomainEvent;
entity: BaseEntity<State>;
}): void | Promise<void>;
};
4 changes: 2 additions & 2 deletions packages/eventive/src/eventive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function eventive<
entity: BaseEntity<State>;
}) => {
for (const plugin of plugins) {
plugin.beforeCommit?.({
await plugin.beforeCommit?.({
event: options.mapper?.(event) ?? event,
entity,
});
Expand All @@ -144,7 +144,7 @@ export function eventive<
}

for (const plugin of plugins) {
plugin.onCommitted?.({
await plugin.onCommitted?.({
event: options.mapper?.(event) ?? event,
entity,
});
Expand Down

0 comments on commit ad05bce

Please sign in to comment.