@mainframe/rpc-stream
Stream-based RPC
Last updated 2 years ago by paul_lecam .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mainframe/rpc-stream 
SYNC missed versions from official npm registry.

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 @mainframe/rpc-stream

Usage

import StreamRPC from '@mainframe/rpc-stream'
import ipcTransport from '@mainframe/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

Current Tags

  • 0.3.0                                ...           latest (2 years ago)

8 Versions

  • 0.3.0                                ...           2 years ago
  • 0.2.5                                ...           2 years ago
  • 0.2.4                                ...           2 years ago
  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           3 years ago

Copyright 2014 - 2016 © taobao.org |