RPC client for browsers
Purpose
RPC client factory, returning a RequestRPC instance using the HTTP transport if the provided endpoint is a HTTP URL, or a StreamRPC instance using the WebSocket transport if the provided endpoint is a WebSocket URL.
Installation
npm install @erebos/rpc-browser
Usage
import { createRPC } from '@erebos/rpc-browser'
const rpcOverHTTP = createRPC('http://localhost') // RequestRPC using HTTP transport
const rpcOverWS = createRPC('ws://localhost') // StreamRPC using WebSocket transport
API
createRPC()
Arguments
endpoint: string: HTTP or WebSocket URL to connect to.
Returns RequestRPC (with HTTP endpoint) or StreamRPC (with WebSocket endpoint).
