mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
unwrap possible observables from IPC-messaging
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
02aa3217c3
commit
ecc3aa0820
@ -2,19 +2,22 @@
|
|||||||
// https://www.electronjs.org/docs/api/ipc-main
|
// https://www.electronjs.org/docs/api/ipc-main
|
||||||
// https://www.electronjs.org/docs/api/ipc-renderer
|
// https://www.electronjs.org/docs/api/ipc-renderer
|
||||||
|
|
||||||
import { ipcMain, ipcRenderer, webContents, remote } from "electron";
|
import { ipcMain, ipcRenderer, remote, webContents } from "electron";
|
||||||
import { toJS } from "mobx";
|
import { toJS } from "mobx";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../main/logger";
|
||||||
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
||||||
|
|
||||||
const subFramesChannel = "ipc:get-sub-frames";
|
const subFramesChannel = "ipc:get-sub-frames";
|
||||||
|
|
||||||
export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) {
|
export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) {
|
||||||
ipcMain.handle(channel, listener);
|
ipcMain.handle(channel, (event: Electron.IpcMainInvokeEvent, ...args: any[]) => {
|
||||||
|
args = toJS(args); // unwrap possibly leaking observable values
|
||||||
|
return listener(event, ...args);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function requestMain(channel: string, ...args: any[]) {
|
export async function requestMain(channel: string, ...args: any[]) {
|
||||||
return ipcRenderer.invoke(channel, ...args);
|
return ipcRenderer.invoke(channel, ...toJS(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubFrames(): ClusterFrameInfo[] {
|
function getSubFrames(): ClusterFrameInfo[] {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user