Setu-TS
    Preparing search index...

    Function defineDomainEvent

    • Runtime-bound abstract bases for ergonomic construction.

      Call once per app with ctx.runtime; returns abstract classes that can be extended and constructed as new X(data) without threading runtime.

      Parameters

      Returns {
          DomainEvent: new <T>(
              data: T,
              opts?: { aggregateId?: string; version?: number },
          ) => DomainEvent<T>;
          IntegrationEvent: new <T>(
              data: T,
              opts?: { aggregateId?: string; version?: number },
          ) => IntegrationEvent<T>;
      }

      Runtime-bound { DomainEvent, IntegrationEvent } abstract bases

      const { DomainEvent } = defineDomainEvent(ctx.runtime);
      class UserCreated extends DomainEvent<{ userId: string }> {
      readonly type = 'UserCreated';
      }
      const event = new UserCreated({ userId: '123' });

      0.1.0