RootDomainEvent
Defined in: packages/ddd-core/domain/events/root-domain.event.ts:146
A DomainEvent carrying aggregate identity/version and a detached, frozen state payload snapshot captured at event creation time.
The snapshot is deep-cloned from the aggregate, so later aggregate mutations
never reach it. Every consumer shares the same payload instance: its own
properties are frozen, but Date/Map/Set internals can still be changed
through their prototype methods (see deepCloneAndFreeze). A consumer
that must not observe changes made by another consumer reads
RootDomainEvent.clonePayload instead. Transports should serialize an
explicit message rather than the payload object itself.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”T = RootEntity<Partial<RootEntitySnapshot>>
The aggregate input type used to infer the snapshot payload.
TPayload
Section titled “TPayload”TPayload = InferPayload<T>
The snapshot payload type.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”
protectednew RootDomainEvent<T,TPayload>(entity,payload?):RootDomainEvent<T,TPayload>
Defined in: packages/ddd-core/domain/events/root-domain.event.ts:159
Parameters
Section titled “Parameters”entity
Section titled “entity”T
payload?
Section titled “payload?”TPayload
Returns
Section titled “Returns”RootDomainEvent<T, TPayload>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”aggregateId?
Section titled “aggregateId?”
readonlyoptionalaggregateId?:string
Defined in: packages/ddd-core/domain/events/root-domain.event.ts:154
Identity of the aggregate that raised the event.
aggregateVersion?
Section titled “aggregateVersion?”
readonlyoptionalaggregateVersion?:number
Defined in: packages/ddd-core/domain/events/root-domain.event.ts:157
Aggregate version at the moment the event was raised.
readonlyid:string
Defined in: packages/ddd-core/domain/events/domain.event.ts:14
Inherited from
Section titled “Inherited from”payload
Section titled “payload”
readonlypayload:Readonly<TPayload>
Defined in: packages/ddd-core/domain/events/root-domain.event.ts:151
Detached, frozen state captured when the event was raised; shared by all consumers.
Methods
Section titled “Methods”clonePayload()
Section titled “clonePayload()”clonePayload():
Readonly<TPayload>
Defined in: packages/ddd-core/domain/events/root-domain.event.ts:187
Returns a new detached, frozen copy of payload on every call, so a change one consumer forces through a Date/Map/Set prototype method stays out of the shared payload and out of other copies.
Returns
Section titled “Returns”Readonly<TPayload>