@dolittle/sdk.aggregates
Version:
Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.
36 lines (26 loc) • 985 B
text/typescript
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
import { EventSourceId } from '@dolittle/sdk.events';
import { AggregateRoot } from '../../AggregateRoot';
import { on } from '../../onDecorator';
import { EventWithOnMethod, EventWithoutOnMethod } from './events';
export class AnAggregateRoot extends AggregateRoot {
readonly onMethodEventsCalled: any[] = [];
constructor(eventSourceId: EventSourceId) {
super(eventSourceId);
}
applyWithOnMethod(event: EventWithOnMethod) {
this.apply(event);
}
applyWithoutOnMethod(event: EventWithoutOnMethod) {
this.apply(event);
}
applyBoth(first: EventWithOnMethod, second: EventWithoutOnMethod) {
this.apply(first);
this.apply(second);
}
(EventWithOnMethod)
onEvent(event: EventWithOnMethod) {
this.onMethodEventsCalled.push(event);
}
}