iron-ipc
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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
    ...
});
 

Package Sidebar

Install

npm i iron-ipc

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

6.37 kB

Total Files

6

Last publish

Collaborators

  • waltcow