Interface Stream<T, K, I, State>

Interface for streams returned by the streaming methods of the Ledger class. Each 'change' event contains accumulated state of type State as well as the ledger events that triggered the current state change.

T The contract template type.

K The contract key type.

I The contract id type.

State The accumulated state.

interface Stream<T extends object, K, I extends string, State> {
    close(): void;
    off(type: "live", listener: (state: State) => void): void;
    off(
        type: "change",
        listener: (state: State, events: readonly Event<T, K, I>[]) => void,
    ): void;
    off(type: "close", listener: (closeEvent: StreamCloseEvent) => void): void;
    on(type: "live", listener: (state: State) => void): void;
    on(
        type: "change",
        listener: (state: State, events: readonly Event<T, K, I>[]) => void,
    ): void;
    on(type: "close", listener: (closeEvent: StreamCloseEvent) => void): void;
}

Type Parameters

  • T extends object
  • K
  • I extends string
  • State

Methods

Methods

  • Close the Stream and stop receiving events.

    Returns void

  • Remove the registered callback for the 'live' event.

    Parameters

    • type: "live"

      'live'

    • listener: (state: State) => void

      function to be deregistered.

    Returns void

  • Remove the registered callback for the 'change' event.

    Parameters

    • type: "change"

      'change'

    • listener: (state: State, events: readonly Event<T, K, I>[]) => void

      function to be deregistered.

    Returns void

  • Remove the registered callback for the 'close' event.

    Parameters

    • type: "close"

      'close'

    • listener: (closeEvent: StreamCloseEvent) => void

      function to be deregistered.

    Returns void

  • Register a callback that will be called when the state of the stream has caught up with the Active Contract Set and is now receiving new transactions.

    Parameters

    • type: "live"

      'live'

    • listener: (state: State) => void

      function taking the state of the stream as an argument.

    Returns void

  • Register a callback that will be called when the state of the stream changes, eg. new contract creates or archives.

    Parameters

    • type: "change"

      'change'

    • listener: (state: State, events: readonly Event<T, K, I>[]) => void

      function taking the state of the stream and new events as arguments.

    Returns void

  • Register a callback that will be called when the underlying stream is closed.

    Parameters

    • type: "close"

      'close'

    • listener: (closeEvent: StreamCloseEvent) => void

      a function taking a StreamCloseEvent as an argument.

    Returns void