mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
feat(core): add module scaffolding and provider registries
This commit is contained in:
27
src/ipc/renderer-api.ts
Normal file
27
src/ipc/renderer-api.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { ipcRenderer, IpcRendererEvent } from "electron";
|
||||
import {
|
||||
MainToRendererEventChannel,
|
||||
RendererToMainInvokeChannel,
|
||||
RendererToMainSendChannel,
|
||||
} from "./contract";
|
||||
|
||||
export function invokeFromRenderer<T>(
|
||||
channel: RendererToMainInvokeChannel,
|
||||
...args: unknown[]
|
||||
): Promise<T> {
|
||||
return ipcRenderer.invoke(channel, ...args) as Promise<T>;
|
||||
}
|
||||
|
||||
export function sendFromRenderer(
|
||||
channel: RendererToMainSendChannel,
|
||||
...args: unknown[]
|
||||
): void {
|
||||
ipcRenderer.send(channel, ...args);
|
||||
}
|
||||
|
||||
export function onMainEvent(
|
||||
channel: MainToRendererEventChannel,
|
||||
listener: (event: IpcRendererEvent, ...args: unknown[]) => void,
|
||||
): void {
|
||||
ipcRenderer.on(channel, listener);
|
||||
}
|
||||
Reference in New Issue
Block a user