iron-ipc
v1.0.4
Published
A type-safe library for strict typing in Electron's IPC modules
Downloads
9
Maintainers
Readme
iron-ipc
Module for type-safe inter process communication (IPC) in electron.
Installation
yarn add iron-ipc
Usage
create custom ipc module
import * as electron from 'electron';
import { IronIpcMain, IronIpcRenderer } from 'iron-ipc';
export const enum Channel {
addTodos: "addTodos";
removeTodos: "removeTodos";
}
interface IpcChannelMap {
[Channel.addTodos]: {
id: number,
title: string,
content: string
};
[Channel.removeTodos]: number
}
const ipcRenderer: IronIpcRenderer<IpcChannelMap> = electron.ipcRenderer;
const ipcMain: IronIpcMain<IpcChannelMap> = electron.ipcMain;
export { ipcMain, ipcRenderer };
use it in renderer or main process
import { ipcMain, Channel } from "shard/ipc"
ipcMain.on(Channel.addTodos, (event, payload) => {
let title = payload.title
...
});