mime-chat/src/modules/ipc.ts

23 lines
487 B
TypeScript

export const useIpc = () => {
const invoke = async (endpoint: string, payload: any) => {
try {
const res = await window.ipcRenderer.invoke(endpoint, payload);
return res;
} catch (e) {
throw e;
}
}
const post = (endpoint: string, payload: any) => {
window.postMessage({
endpoint: endpoint,
content: payload
}, '*')
};
return {
invoke,
post
}
}