Skip to content

IDomainEventPublisher

Defined in: packages/ddd-core/application/ports/domain-event-publisher.port.ts:20

Publishes the buffered domain events of an aggregate after a command succeeds.

Any bus with a publishAll(events) method fits, including the NestJS CQRS EventBus, so a Nest handler passes its injected EventBus unchanged. CommandBaseHandler passes the aggregate as dispatcherContext, which the NestJS EventBus hands to its configured publisher.

const publisher: IDomainEventPublisher = {
publishAll: (events) => events.forEach((event) => emitter.emit('event', event)),
};

publishAll(events, dispatcherContext?): unknown

Defined in: packages/ddd-core/application/ports/domain-event-publisher.port.ts:21

IEvent[]

unknown

unknown