StreamRPC client (stateful)
Purpose
Class extending BaseRPC
to handle stateless JSON-RPC 2.0 calls.
See the IPC transport
and WebSocket transports
documentation for possible transports and the RequestRPC
class documentation to handle stateless JSON-RPC 2.0 calls.
Installation
npm install @erebos/rpc-stream
Usage
import { StreamRPC } from '@erebos/rpc-stream'
import { createTransport } from '@erebos/transport-ipc'
class MyAPI extends StreamRPC {
constructor(path: string) {
super(createTransport(path))
}
getUser(id: string): Promise<{ name: string }> {
return this.request('getUser', [id])
}
}
const api = new MyAPI('/path/to/socket')
api.getUser('1234')
StreamRPC class
See the BaseRPC
documentation for inherited methods and properties.
new StreamRPC()
Arguments
subject: Subject
: a RxJSSubject
handling communication with the server.
.request()
Arguments
method: string
params: T = any
Returns Promise<R = any>