UNPKG

988 BTypeScriptView Raw
1import { EventInterface } from 'microevent.ts';
2interface RpcProviderInterface {
3 dispatch(message: any): void;
4 rpc<T = void, U = void>(id: string, payload?: T, transfer?: Array<any>): Promise<U>;
5 signal<T = void>(id: string, payload?: T, transfer?: Array<any>): this;
6 registerRpcHandler<T = void, U = void>(id: string, handler: RpcProviderInterface.RpcHandler<T, U>): this;
7 registerSignalHandler<T = void>(id: string, handler: RpcProviderInterface.SignalHandler<T>): this;
8 deregisterRpcHandler<T = void, U = void>(id: string, handler: RpcProviderInterface.RpcHandler<T, U>): this;
9 deregisterSignalHandler<T = void>(id: string, handler: RpcProviderInterface.SignalHandler<T>): this;
10 error: EventInterface<Error>;
11}
12declare module RpcProviderInterface {
13 interface RpcHandler<T = void, U = void> {
14 (payload: T): Promise<U> | U;
15 }
16 interface SignalHandler<T = void> {
17 (payload: T): void;
18 }
19}
20export default RpcProviderInterface;