AggregateRoot
Represents an aggregate root. An aggregate root is an entity that represents a meaningful concept in the domain. It is the root of an aggregate, which is a cluster of domain objects that can be treated as a single unit.
abstract class AggregateRoot<EventBase extends IEvent = IEvent> {
autoCommit: boolean
publish<T extends EventBase = EventBase>(event: T)
publishAll<T extends EventBase = EventBase>(events: T[])
commit()
uncommit()
getUncommittedEvents(): EventBase[]
loadFromHistory(history: EventBase[])
apply<T extends EventBase = EventBase>(event: T, optionsOrIsFromHistory: boolean | { fromHistory?: boolean; skipHandler?: boolean; } = {}): void
protected getEventHandler<T extends EventBase = EventBase>(event: T): Type<IEventHandler> | undefined
protected getEventName(event: any): string
}
Properties
| Property | Description |
|---|---|
autoCommit: boolean
|
Gets whether the aggregate root should automatically commit events. |
Methods
publish() |
|---|
|
Publishes an event. Must be merged with the publisher context in order to work. |
publishAll() |
|---|
|
Publishes multiple events. Must be merged with the publisher context in order to work. |
commit() |
|---|
|
Commits all uncommitted events. |
ParametersThere are no parameters. |
uncommit() |
|---|
|
Uncommits all events. |
ParametersThere are no parameters. |
getUncommittedEvents() |
|---|
|
Returns all uncommitted events. |
ParametersThere are no parameters. Returns
|
loadFromHistory() |
|---|
|
Loads events from history. |
getEventHandler() | ||||||
|---|---|---|---|---|---|---|
Parameters
Returns
|
getEventName() |
|---|