Documentation - v7.4.0
    Preparing search index...

    Interface Hook<Params, Result>

    A typed publish/subscribe hook used to assemble SDK events.

    Multiple callbacks can be registered. When trigger is called, each callback receives the same params and may return:

    • A Result value — merged with the other callbacks' results via combine.
    • SKIPPED — this callback contributes nothing; processing continues.
    • DISCARDED — the entire event is dropped; no further callbacks are invoked.
    interface Hook<Params, Result> {
        register(
            this: void,
            callback: (params: Params) => Result | "DISCARDED" | "SKIPPED",
        ): { unregister: () => void };
        trigger(this: void, params: Params): Result | "DISCARDED" | undefined;
    }

    Type Parameters

    • Params

      The input passed to every registered callback.

    • Result

      The type of the assembled output value.

    Index

    Methods

    • Registers a callback and returns a handle to unregister it.

      Parameters

      • this: void
      • callback: (params: Params) => Result | "DISCARDED" | "SKIPPED"

      Returns { unregister: () => void }

    • Invokes all registered callbacks with params and deep-merges their results. Returns DISCARDED if any callback discards the event, or undefined if no callback returns a result.

      Parameters

      Returns Result | "DISCARDED" | undefined