werkbank
    Preparing search index...

    Function createClient

    • Creates an RPC client that connects to a Worker or SharedWorker.

      Type Parameters

      • Config

        The type of the worker's API configuration.

      Parameters

      • worker: SharedWorker | Worker

        The Worker or SharedWorker instance to connect to.

      Returns RpcClient<Config>

      The typed RPC client.

      This function establishes a connection with the worker and returns a proxy object that mirrors the worker's API.

      const worker = new Worker("./worker.js");
      const client = createClient<MyApi>(worker);
      await client.someMethod();