import { DomainEvent } from './DomainEvent' ; export abstract class AggregateRoot { private domainEvents : Array < DomainEvent > ; constructor ( ) { this . domainEvents = [ ] ; } pullDomainEvents ( ) { const domainEvents = this . domainEvents . slice ( ) ; this . domainEvents = [ ] ; return domainEvents ; } record ( event ) { this . domainEvents . push ( event ) ; } abstract toPrimitives ( ) ; }