swarpc - v0.19.0
    Preparing search index...

    Type Alias SwarpcClient<Procedures>

    SwarpcClient: {
        "[zProcedures]": Procedures;
        onceBy: (
            key: string,
        ) => { [F in keyof Procedures]: ClientMethodCallable<Procedures[F]> };
        destroy(): void;
    } & { [F in keyof Procedures]: ClientMethod<Procedures[F]> }

    The sw&rpc client instance, which provides methods to call procedures. Each property of the procedures map will be a method, that accepts an input, an optional onProgress callback and an optional request ID. If you want to be able to cancel the request, you can set the request's ID yourself, and call .abort(requestId, reason) on the client instance to cancel it.

    Type Parameters

    Type Declaration

    • [zProcedures]: Procedures
    • onceBy: (
          key: string,
      ) => { [F in keyof Procedures]: ClientMethodCallable<Procedures[F]> }

      Create a proxy that cancels any ongoing call with the given global key before running new calls. Usage: await swarpc.onceBy("global-key").myMethod(...)

    • destroy: function
      • Disconnects all event listeners created by the client, and:

        • for Shared Workers: closes the port started by the client
        • for Dedicated Workers: terminates the worker instance
        • for Service Workers: does nothing (there is no connection to close)

        Returns void