domain-toolkit
    Preparing search index...

    Function Handle

    • Marks a method as the aggregate's reaction to one kind of event.

      class BookStock extends AggregateRoot<TitleId> {
      @Handle(CopyCheckedOut)
      protected onCopyCheckedOut(event: CopyCheckedOut): void { ... }
      }

      Registration happens under event.eventName — the same string an instance reports as its name, so AggregateRoot.apply can find this method again from an event it holds.

      The decorator runs when the class is defined, not when it is instantiated, so a missing eventName fails at import time rather than at dispatch.

      What breaks when registration keys on the class name instead: ../../../docs/handle-decorator.md

      Parameters

      Returns (
          target: AggregateRoot,
          propertyKey: string,
          descriptor: PropertyDescriptor,
      ) => PropertyDescriptor