Abstract Class: AggregateRoot<T>
Entity base that buffers domain events raised by an aggregate. Events remain in memory until pulled or cleared; this class does not publish them.
Extends
Entity<T>
Type Parameters
T
T extends Identifier
Implements
Constructors
Constructor
new AggregateRoot<
T>(id):AggregateRoot<T>
Initializes a new instance of the Entity class.
Parameters
id
T
The unique identifier for the entity.
Returns
AggregateRoot<T>
Inherited from
Properties
_id
protectedreadonly_id:T
Inherited from
Accessors
id
Get Signature
get id():
Readonly<T>
Gets the unique identifier for the entity.
Returns
Readonly<T>
The unique identifier for the entity.
Inherited from
Methods
addDomainEvent()
addDomainEvent(
event):void
Adds a domain event to the aggregate root's list of domain events. This method allows the aggregate root to track events that have occurred within its context, which can be used for event sourcing or other domain-driven design patterns.
Parameters
event
The domain event to be added to the aggregate root's list of domain events.
Returns
void
clearDomainEvents()
clearDomainEvents():
void
Clears all domain events from the aggregate root. This method allows the aggregate root to reset its state.
Returns
void
equals()
equals(
other):boolean
Determines whether the current entity is equal to another entity of the same type.
Parameters
other
Entity<T>
The other entity to compare with.
Returns
boolean
True if the entities are equal; otherwise, false.
Inherited from
pullDomainEvents()
pullDomainEvents():
DomainEvent[]
Pulls all domain events from the aggregate root and clears the list of domain events. This method allows the aggregate root to retrieve its domain events and reset its state.
Returns
An array of domain events that were associated with the aggregate root.