@lppedd/message-bus - v0.9.1
    Preparing search index...

    Type Alias MessageHandler<T, R>

    MessageHandler: (data: T, ...other: any[]) => R | Promise<R>

    A function that handles messages published to a specific Topic.

    Message handlers are registered using MessageBus.subscribe or MessageBus.subscribeOnce. They are invoked whenever a message is published to the corresponding topic.

    Type Parameters

    • T = unknown

      The type of the payload data received by the handler.

    • R = unknown

      The type of the value returned by the handler. Defaults to void, which means nothing is returned.

    Type Declaration

      • (data: T, ...other: any[]): R | Promise<R>
      • Parameters

        • data: T

          The payload sent with the topic message.

        • ...other: any[]

          Optional additional message handler arguments injected by MessageInterceptor(s).

        Returns R | Promise<R>

        The handler's result, which may be returned synchronously or as a promise. Defaults to void, which means nothing is returned.

    bus.subscribe(UserCreatedTopic, async (user) => {
    await sendWelcomeEmail(user);
    });