14.1.0 • Published 11 months ago

stream-electron-ipc v14.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
11 months ago

stream-electron-ipc

electron.ipcMain and electron.ipcRenderer as Duplex streams

Usage

main

import { ElectronIpcMainDuplex } from 'stream-electron-ipc';

...
const someWebContents: Electron.WebContents = ...;
const channel = 'my-custom-channel';
const duplex = new ElectronIpcMainDuplex(someWebContents, channel);
duplex.write(...); // writes to underlying webContents through ipc
duplex.on('data', (...) => {
  // Callback called when underlying webContents sends data through ipc
})

renderer

import { ElectronIpcRendererDuplex } from 'stream-electron-ipc';

// Connect to main process
const someWebContentsId = 0; // 0 is always the main process
const channel = 'my-custom-channel'; // Same channel as in other process
const duplex = new ElectronIpcRendererDuplex(someWebContentsId, channel);
duplex.write(...); // writes to main process through ipc
duplex.on('data', (...) => {
  // Callback called when main process sends data through this duplex
})

// Connect to another renderer
const someWebContentsId = 12;
const channel = 'my-custom-channel'; // Same channel as in other process
const duplex = new ElectronIpcRendererDuplex(someWebContentsId, channel);
duplex.write(...); // writes to the renderer process through ipc
duplex.on('data', (...) => {
  // Callback called when renderer process sends data through this duplex
})
14.0.0

12 months ago

14.1.0

11 months ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago