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.
yarn add @erebos/rpc-streamimport 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')See the BaseRPC API for inherited methods and properties.
Arguments
subject: Subject: a RxJSSubjecthandling communication with the server.
Arguments
method: stringparams: T = any
Returns Promise<R = any>
MIT