FynMesh API
    Preparing search index...

    Interface FynBus

    Messaging API available to FynApps as runtime.bus and to kernel-side code as kernel.bus.

    interface FynBus {
        channel(name: string): FynBus;
        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

    • 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>