worker-rpc

  • Version 0.2.0
  • Published
  • 36.2 kB
  • 1 dependency
  • MIT license

Install

npm i worker-rpc
yarn add worker-rpc
pnpm add worker-rpc

Overview

A simple RPC layer for communicating with web workers and over other transports

Index

Classes

class RpcProvider

class RpcProvider implements RpcProviderInterface {}

    constructor

    constructor(_dispatch: RpcProvider.Dispatcher, _rpcTimeout?: number);

      property error

      error: Event<Error>;

        method deregisterRpcHandler

        deregisterRpcHandler: <T = void, U = void>(
        id: string,
        handler: RpcProviderInterface.RpcHandler<T, U>
        ) => this;

          method deregisterSignalHandler

          deregisterSignalHandler: <T = void>(
          id: string,
          handler: RpcProviderInterface.SignalHandler<T>
          ) => this;

            method dispatch

            dispatch: (payload: any) => void;

              method registerRpcHandler

              registerRpcHandler: <T = void, U = void>(
              id: string,
              handler: RpcProviderInterface.RpcHandler<T, U>
              ) => this;

                method registerSignalHandler

                registerSignalHandler: <T = void>(
                id: string,
                handler: RpcProviderInterface.SignalHandler<T>
                ) => this;

                  method rpc

                  rpc: <T = void, U = void>(id: string, payload?: T, transfer?: any) => Promise<U>;

                    method signal

                    signal: <T = void>(id: string, payload?: T, transfer?: any) => this;

                      Interfaces

                      interface RpcProviderInterface

                      interface RpcProviderInterface {}

                        property error

                        error: EventInterface<Error>;

                          method deregisterRpcHandler

                          deregisterRpcHandler: <T = void, U = void>(
                          id: string,
                          handler: RpcProviderInterface.RpcHandler<T, U>
                          ) => this;

                            method deregisterSignalHandler

                            deregisterSignalHandler: <T = void>(
                            id: string,
                            handler: RpcProviderInterface.SignalHandler<T>
                            ) => this;

                              method dispatch

                              dispatch: (message: any) => void;

                                method registerRpcHandler

                                registerRpcHandler: <T = void, U = void>(
                                id: string,
                                handler: RpcProviderInterface.RpcHandler<T, U>
                                ) => this;

                                  method registerSignalHandler

                                  registerSignalHandler: <T = void>(
                                  id: string,
                                  handler: RpcProviderInterface.SignalHandler<T>
                                  ) => this;

                                    method rpc

                                    rpc: <T = void, U = void>(
                                    id: string,
                                    payload?: T,
                                    transfer?: Array<any>
                                    ) => Promise<U>;

                                      method signal

                                      signal: <T = void>(id: string, payload?: T, transfer?: Array<any>) => this;

                                        Namespaces

                                        namespace RpcProvider

                                        namespace RpcProvider {}

                                          interface Dispatcher

                                          interface Dispatcher {}

                                            call signature

                                            (message: Message, transfer?: Array<any>): void;

                                              interface Message

                                              interface Message {}

                                                property id

                                                id: string;

                                                  property payload

                                                  payload?: any;

                                                    property transactionId

                                                    transactionId?: number;

                                                      property type

                                                      type: MessageType;

                                                        enum MessageType

                                                        enum MessageType {
                                                        signal = 0,
                                                        rpc = 1,
                                                        internal = 2,
                                                        }

                                                          member internal

                                                          internal = 2

                                                            member rpc

                                                            rpc = 1

                                                              member signal

                                                              signal = 0

                                                                namespace RpcProviderInterface

                                                                namespace RpcProviderInterface {}

                                                                  interface RpcHandler

                                                                  interface RpcHandler<T = void, U = void> {}

                                                                    call signature

                                                                    (payload: T): Promise<U> | U;

                                                                      interface SignalHandler

                                                                      interface SignalHandler<T = void> {}

                                                                        call signature

                                                                        (payload: T): void;

                                                                          Package Files (3)

                                                                          Dependencies (1)

                                                                          Dev Dependencies (5)

                                                                          Peer Dependencies (0)

                                                                          No peer dependencies.

                                                                          Badge

                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/worker-rpc.

                                                                          • Markdown
                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/worker-rpc)
                                                                          • HTML
                                                                            <a href="https://www.jsdocs.io/package/worker-rpc"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>