MCPcopy
hub / github.com/CopyTranslator/CopyTranslator / startService

Function startService

src/proxy/main.ts:4–25  ·  view source on GitHub ↗
(proxy: T, key: string)

Source from the content-addressed store, hash-verified

2import { isPromise } from "./helper";
3
4export function startService<T>(proxy: T, key: string) {
5 ipcMain.on("proxy-service", (event: any, arg: any) => {
6 if (arg.type === key) {
7 const res = (proxy as any)[arg.method](...arg.args);
8 if (isPromise(res)) {
9 res.then((result: any) => {
10 event.sender.send(`proxy-service-res-${arg.promiseCounter}`, {
11 succeed: true,
12 result,
13 promiseCounter: arg.promiseCounter,
14 });
15 });
16 } else {
17 event.sender.send(`proxy-service-res-${arg.promiseCounter}`, {
18 succeed: true,
19 result: res,
20 promiseCounter: arg.promiseCounter,
21 });
22 }
23 }
24 });
25}

Callers 1

createWindowMethod · 0.90

Calls 2

isPromiseFunction · 0.90
onMethod · 0.80

Tested by

no test coverage detected