Skip to content

Commit

Permalink
Merge pull request #515 from reify-joe-eckard/feature/bind-latest-ver…
Browse files Browse the repository at this point in the history
…sion-provider-fix

bind this to latestVersionProvider
  • Loading branch information
idugalic authored Aug 10, 2023
2 parents b1db11f + 4986abf commit 1bb1455
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/lib/application/eventsourcing-aggregate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import {
EventSourcingAggregate,
EventSourcingLockingAggregate,
EventSourcingOrchestratingAggregate,
EventSourcingOrchestratingLockingAggregate,
IEventSourcingAggregate,
IEventSourcingLockingAggregate,
IEventSourcingOrchestratingAggregate,
IEventSourcingOrchestratingLockingAggregate,
LatestVersionProvider,
} from './eventsourcing-aggregate';

Expand Down Expand Up @@ -383,6 +385,18 @@ const aggregate4: IEventSourcingOrchestratingAggregate<
OddNumberEvt | EvenNumberEvt
>(decider.combine(decider2), repository3, saga);

const aggregateLocking4: IEventSourcingOrchestratingLockingAggregate<
EvenNumberCmd | OddNumberCmd,
readonly [number, number],
OddNumberEvt | EvenNumberEvt,
number
> = new EventSourcingOrchestratingLockingAggregate<
EvenNumberCmd | OddNumberCmd,
readonly [number, number],
OddNumberEvt | EvenNumberEvt,
number
>(decider.combine(decider2), repositoryLocking2, saga);

// ################################
// ############ Tests #############
// ################################
Expand Down Expand Up @@ -429,3 +443,10 @@ test('aggregate-handle6', async (t) => {
new EvenNumberAddedEvt(8),
]);
});

test('aggregate-locking-handle6', async (t) => {
t.deepEqual(await aggregateLocking4.handle(new AddOddNumberCmd(7)), [
[new OddNumberAddedEvt(7), 1],
[new EvenNumberAddedEvt(8), 2],
]);
});
2 changes: 1 addition & 1 deletion src/lib/application/eventsourcing-aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export class EventSourcingOrchestratingLockingAggregate<C, S, E, V>
async (c: C) =>
(await this.eventRepository.fetchEvents(c)).map((it) => it[0])
),
this.latestVersionProvider
this.latestVersionProvider.bind(this)
);
}
}
Expand Down

0 comments on commit 1bb1455

Please sign in to comment.