Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Interface TypedEventBus<EventMap>

    The typed pub/sub surface.

    interface TypedEventBus<EventMap> {
        on<K extends string | number | symbol>(
            type: K,
            listener: (payload: EventMap[K]) => void,
            options?: { replayLast?: boolean },
        ): Unsubscribe;
        emit<K extends string | number | symbol>(
            type: K,
            payload: EventMap[K],
        ): void;
        hasListeners(type: keyof EventMap): boolean;
        clear(type?: keyof EventMap): void;
    }

    Type Parameters

    • EventMap
    Index
    • Subscribe to type. Returns an unsubscribe thunk that callers should store (e.g., in an EventGroup or a dispose() list).

      replayLast: true causes the last emitted payload for type, if any, to fire immediately on subscription. Useful for late-binding panels that need the current value (e.g., FPS counter that wants to show something before the next frame).

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • type: K
      • listener: (payload: EventMap[K]) => void
      • Optionaloptions: { replayLast?: boolean }

      Returns Unsubscribe

    • Emit payload to every subscriber of type. No-op if no one is listening (events drop silently — that's the design).

      Type Parameters

      • K extends string | number | symbol

      Parameters

      Returns void

    • Whether at least one listener is currently subscribed to type. Lets producers gate expensive work behind "anyone consuming?" (e.g. GPU picking only runs when a selection listener exists).

      Parameters

      Returns boolean

    • Drop all subscribers (or just those for type). Used by tests that share the singleton between cases. Production code should use the per-subscription unsubscribe instead.

      Parameters

      Returns void