mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
25 lines
641 B
JavaScript
25 lines
641 B
JavaScript
|
// @flow
|
||
|
import type { ServiceError } from './service-error';
|
||
|
import { GrpcResponseEventEnum } from '../../common/grpc-events';
|
||
|
|
||
|
interface IResponseCallbacks {
|
||
|
sendData(requestId: string, val: Object | undefined): void;
|
||
|
sendError(requestId: string, err: ServiceError): void;
|
||
|
}
|
||
|
|
||
|
export class ResponseCallbacks implements IResponseCallbacks {
|
||
|
_event: IpcMainEvent = null;
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
}
|