PromoCursed/node_modules/fork-ts-checker-webpack-plugin/lib/rpc/RpcService.d.ts
2024-08-20 23:25:37 +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 };