the-forest/client/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/RpcService.d.ts
2024-09-17 20:35:18 -04:00

13 lines
703 B
TypeScript

import { RpcProcedure } from './RpcProcedure';
import { RpcMessagePort } from './RpcMessagePort';
declare type RpcCallHandler<TPayload = any, TResult = any> = (payload: TPayload) => Promise<TResult>;
interface RpcService {
readonly isOpen: () => boolean;
readonly open: () => Promise<void>;
readonly close: () => Promise<void>;
readonly addCallHandler: <TPayload, TResult>(procedure: RpcProcedure<TPayload, TResult>, handler: RpcCallHandler<TPayload, TResult>) => void;
readonly removeCallHandler: <TPayload, TResult>(procedure: RpcProcedure<TPayload, TResult>) => void;
}
declare function createRpcService(port: RpcMessagePort): RpcService;
export { RpcService, createRpcService };