insomnia/packages/insomnia-app/app/main/grpc-ipc-main.ts
Dimitri Mitropoulos 5f4c19da35
[TypeScript] Phase 1 & 2 (#3370)
Co-authored-by: Opender Singh <opender.singh@konghq.com>
2021-05-12 18:35:00 +12:00

21 lines
902 B
TypeScript

import * as grpc from '../network/grpc';
import { ipcMain } from 'electron';
import { GrpcRequestEventEnum } from '../common/grpc-events';
import { ResponseCallbacks } from '../network/grpc/response-callbacks';
import { GrpcIpcRequestParams } from '../network/grpc/prepare';
export function init() {
ipcMain.on(GrpcRequestEventEnum.start, (e, params: GrpcIpcRequestParams) =>
grpc.start(params, new ResponseCallbacks(e)),
);
ipcMain.on(GrpcRequestEventEnum.sendMessage, (e, params: GrpcIpcRequestParams) =>
// @ts-expect-error -- TSCONVERSION
grpc.sendMessage(params, new ResponseCallbacks(e)),
);
ipcMain.on(GrpcRequestEventEnum.commit, (_, requestId) => grpc.commit(requestId));
ipcMain.on(GrpcRequestEventEnum.cancel, (_, requestId) => grpc.cancel(requestId));
ipcMain.on(GrpcRequestEventEnum.cancelMultiple, (_, requestIdS) =>
grpc.cancelMultiple(requestIdS),
);
}