14.1.0 • Published 2 years ago

stream-electron-ipc v14.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years 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

2 years ago

14.1.0

2 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago