UNPKG

@jsonjoy.com/reactive-rpc

Version:

Reactive-RPC is a library for building reactive APIs over WebSocket, HTTP, and other RPCs.

22 lines (21 loc) 976 B
import type { Observable } from 'rxjs'; import * as msg from '../messages'; import type { StreamingRpcClient } from './client/StreamingRpcClient'; import type { RpcMessageStreamProcessor } from './RpcMessageStreamProcessor'; export interface RpcDuplexParams<Ctx = unknown> { client: StreamingRpcClient; server: RpcMessageStreamProcessor<Ctx>; } export declare class RpcDuplex<Ctx = unknown> { readonly client: StreamingRpcClient; readonly server: RpcMessageStreamProcessor<Ctx>; constructor(params: RpcDuplexParams<Ctx>); onMessages(messages: msg.ReactiveRpcMessage[], ctx: Ctx): void; onMessage(message: msg.ReactiveRpcMessage, ctx: Ctx): void; call$(method: string, data: unknown): Observable<unknown>; call$(method: string, data: Observable<unknown>): Observable<unknown>; call(method: string, data: unknown): Promise<unknown>; notify(method: string, data: undefined | unknown): void; stop(): void; disconnect(): void; }