import { CommandHandler , EventPublisher , ICommandHandler } from '@nestjs/cqrs' ; import { ItemRepository } from '@domain/repositories' ; import { NotifyItemOwnerCommand } from '../../impl' ; @ CommandHandler ( NotifyItemOwnerCommand ) export class NotifyItemOwnerHandler implements ICommandHandler < NotifyItemOwnerCommand > { constructor ( private readonly itemRepository , private readonly publisher ) { } async execute ( command ) { const itemModel = this . publisher . mergeObjectContext ( await this . itemRepository . notifyItemOwner ( command . event ) ) ; itemModel . commit ( ) ; } }