FynMesh API
    Preparing search index...

    Interface FynBusFacade

    Per-source view of the bus. Stamps meta.source on emits, filters self-echo by default, and tracks subscriptions so dispose() can remove them all.

    A closure rather than a class: source, channelName and the shared subscription state are read on nearly every call, and as closure variables they cost one character each instead of a property lookup per use. Channel views are made by calling the factory again with the owning facade's state, so dispose() still covers them.

    interface FynBusFacade {
        channel(name: string): FynBus;
        dispose(): void;
        emit<T = unknown>(topic: string, payload?: T): void;
        handle<TReq = unknown, TRes = unknown>(
            topic: string,
            handler: RequestHandler<TReq, TRes>,
        ): Unsubscribe;
        on<T = unknown>(
            topic: string,
            handler: BusHandler<T>,
            options?: SubscribeOptions,
        ): Unsubscribe;
        once<T = unknown>(
            topic: string,
            handler: BusHandler<T>,
            options?: SubscribeOptions,
        ): Unsubscribe;
        request<TRes = unknown, TReq = unknown>(
            topic: string,
            payload?: TReq,
            options?: RequestOptions,
        ): Promise<TRes>;
    }

    Hierarchy (View Summary)

    Index
    • Scoped view: topics on a named channel are invisible to other channels

      Parameters

      • name: string

      Returns FynBus

    • Unsubscribe everything registered through this facade and its channels

      Returns void

    • Deliver payload synchronously to current subscribers of topic

      Type Parameters

      • T = unknown

      Parameters

      • topic: string
      • Optionalpayload: T

      Returns void

    • Register the single responder for a topic. A second handle() on the same topic throws BUS_HANDLER_EXISTS; the returned unsubscribe frees the topic.

      Type Parameters

      • TReq = unknown
      • TRes = unknown

      Parameters

      Returns Unsubscribe

    • Send a request; resolves with the handler's response, rejects with the handler's error. Waits up to options.timeout for a handler to appear (late-loading FynApps are normal), then rejects with BUS_REQUEST_TIMEOUT. options.signal stops the wait at any point (BUS_REQUEST_ABORTED); an already-invoking handler still runs, its result discarded.

      Type Parameters

      • TRes = unknown
      • TReq = unknown

      Parameters

      Returns Promise<TRes>