Class RPCChannel<LocalAPI, RemoteAPI, Io>

A bidirectional Stdio IPC channel in RPC style. This allows 2 JS/TS processes to call each other's API like using libraries in RPC style, without needing to deal with argv, stdin, stdout directly.

Type Parameters

  • LocalAPI extends Record<string, any>
  • RemoteAPI extends Record<string, any>
  • Io extends IoInterface = IoInterface

Constructors

Methods

  • Calls a method on the remote API

    Type Parameters

    • T extends string | number | symbol

    Parameters

    • method: T

      The name of the method to call

    • args: any[]

      Arguments to pass to the remote method

    Returns Promise<void>

    Promise that resolves with the result of the remote call

  • Exposes a local API implementation that can be called remotely

    Parameters

    • api: LocalAPI

      The local API implementation to expose

    Returns void

  • Frees up memory by clearing stored callbacks and callback cache Useful when dealing with many anonymous callback functions to prevent memory leaks

    Returns void

  • Returns a proxy object that represents the remote API Methods called on this proxy will be executed on the remote endpoint

    Returns RemoteAPI

    Proxy object representing the remote API

  • Returns the IO interface used by this channel

    Returns Io

    The IO interface instance