mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
80e5161a20
* fix non-context-aware imports * extract _actuallySend to file * extract CLI unit test function from renderer * expose curl functions to the ipc renderer * use curl through ipcRenderer * feedback first pass make like grpc * feedback second pass remove duplicate * fix lint
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { ServiceError, StatusObject } from '@grpc/grpc-js';
|
|
import { IpcMainEvent } from 'electron';
|
|
|
|
import { GrpcResponseEventEnum } from '../../common/ipc-events';
|
|
interface IResponseCallbacks {
|
|
sendData(requestId: string, val: Record<string, any> | undefined): void;
|
|
sendError(requestId: string, err: ServiceError): void;
|
|
sendStart(requestId: string): void;
|
|
sendEnd(requestId: string): void;
|
|
sendStatus(requestId: string, status: StatusObject): void;
|
|
}
|
|
export class ResponseCallbacks implements IResponseCallbacks {
|
|
_event: IpcMainEvent;
|
|
|
|
constructor(e: IpcMainEvent) {
|
|
this._event = e;
|
|
}
|
|
|
|
sendData(requestId, val) {
|
|
this._event.reply(GrpcResponseEventEnum.data, requestId, val);
|
|
}
|
|
|
|
sendError(requestId, err) {
|
|
this._event.reply(GrpcResponseEventEnum.error, requestId, err);
|
|
}
|
|
|
|
sendStart(requestId) {
|
|
this._event.reply(GrpcResponseEventEnum.start, requestId);
|
|
}
|
|
|
|
sendEnd(requestId) {
|
|
this._event.reply(GrpcResponseEventEnum.end, requestId);
|
|
}
|
|
|
|
sendStatus(requestId, status) {
|
|
this._event.reply(GrpcResponseEventEnum.status, requestId, status);
|
|
}
|
|
}
|