import { IDomainEvent } from '@/domain/events'

export abstract class AggregateRoot {
  private _domainEvents: IDomainEvent[] = []

  get domainEvents(): IDomainEvent[] {
    return [...this._domainEvents]
  }

  protected addDomainEvent(event: IDomainEvent): void {
    this._domainEvents.push(event)
  }

  clearDomainEvents(): void {
    this._domainEvents = []
  }
}
