Class MessageTransformer<SrcMsg, OutMsg, HandlerOpts>

MessageProcessor that handles input message and transforms it to output message.

Type Parameters

  • SrcMsg

  • OutMsg = SrcMsg

  • HandlerOpts = object

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

close: ((...args) => MaybePromise<void>) = ...

Type declaration

    • (...args): MaybePromise<void>
    • Wraps a MaybePromise-yielding coroutine (generator function) into a function that returns MaybePromise. This allows you to use maybeAsync/yield in a similar way to async/await, where yield maybePromise will return awaited / resolved value.

      Parameters

      Returns MaybePromise<void>

      Example

      const add = maybeAsync(function* (a: number, b: number) {
      const result1: number = yield Promise.resolve(a); // result1 === a
      const result2 = yield b; // result2 === b
      return result + result2;
      });
      const result = await add(1, 2); // result === 3
consumer: MessageHandler<SrcMsg, HandlerOpts>

Consumer of messages.

start: ((...args) => MaybePromise<void>) = ...

Type declaration

    • (...args): MaybePromise<void>
    • Wraps a MaybePromise-yielding coroutine (generator function) into a function that returns MaybePromise. This allows you to use maybeAsync/yield in a similar way to async/await, where yield maybePromise will return awaited / resolved value.

      Parameters

      Returns MaybePromise<void>

      Example

      const add = maybeAsync(function* (a: number, b: number) {
      const result1: number = yield Promise.resolve(a); // result1 === a
      const result2 = yield b; // result2 === b
      return result + result2;
      });
      const result = await add(1, 2); // result === 3
subscription: MessageSubscription<SrcMsg, HandlerOpts>

MessageSubscription to consume.

Accessors

  • get started(): boolean
  • Returns if this has started.

    Returns boolean

Methods

Generated using TypeDoc