minimal-electron-typescript-boilerplate
Version:
Electron-Typescript-React boilerplate with minimal functionality
18 lines (15 loc) • 529 B
text/typescript
import { ipcMain, IpcRendererEvent, IpcMain, IpcMainEvent } from 'electron';
import * as os from 'os';
export const enableIPC = () => {
ipcMain.on('ping', (event: IpcMainEvent, arg: string) => {
console.log('asynchronous', arg);
event.reply('pong', `HuHuHu! [${new Date()}] pong~`);
});
ipcMain.handle('get:homeDir', async (event, path) => {
return await new Promise(resolve =>
setTimeout(() => {
resolve(os.homedir());
}, 5000)
);
});
};