@erebos/rpc-stream
TypeScript icon, indicating that this package has built-in type declarations

0.11.0 • Public • Published

rpc-stream

Class extending rpc-base to handle stateful JSON-RPC 2.0 calls.

See transport-ipc, transport-ws-browser and transport-ws-node for possible transports and rpc-request to handle stateless JSON-RPC 2.0 calls.

Installation

yarn add @erebos/rpc-stream

Usage

import StreamRPC from '@erebos/rpc-stream'
import ipcTransport from '@erebos/transport-ipc'

class MyAPI extends StreamRPC {
  constructor(path: string) {
    super(ipcTransport(path))
  }

  getUser(id: string): Promise<{ name: string }> {
    return this.request('getUser', [id])
  }
}

const api = new MyAPI('/path/to/socket')
api.getUser('1234')

API

See the BaseRPC API for inherited methods and properties.

new StreamRPC()

Arguments

  1. subject: Subject: a RxJS Subject handling communication with the server.

.request()

Arguments

  1. method: string
  2. params: T = any

Returns Promise<R = any>

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @erebos/rpc-stream

Weekly Downloads

4

Version

0.11.0

License

MIT

Unpacked Size

12.9 kB

Total Files

5

Last publish

Collaborators

  • aclarke
  • diogoperillo
  • howleysv
  • mosic
  • paul_lecam
  • sarahwiley