promisify-electron-ipc
v1.3.0
Published
Library to use promises for inter-process communication for electron.
Downloads
7
Readme
promisify-electron-ipc
Library to easily use promises for inter-process communication in electron.
Installation
npm install promisify-electron-ipc
or
yarn add promisify-electron-ipc
Documentation
You can find the documentation here.
Usage
Sending messages from the renderer to the main process:
// In the main process
import { promiseIpcMain } from "promisify-electron-ipc";
promiseIpcMain.on("greet-channel", name => {
return Promise.resolve("Hello " + name);
});
// In the renderer
import { promiseIpcRenderer } from "promisify-electron-ipc";
promiseIpcRenderer
.send("greet-channel", "Bob")
.then(answer => console.log(answer)); // prints "Hello Bob"
Sending messages from the main process to the renderer:
// In the main process
import { promiseIpcMain } from "promisify-electron-ipc";
promiseIpcMain
.send("greet-channel", win.webContents, "Bob")
.then(answer => console.log(answer));
// In the renderer
import { promiseIpcRenderer } from "promisify-electron-ipc";
promiseIpcRenderer.on("greet-channel", name => {
return Promise.resolve("Hello " + name);
});
Credits
This library was inspired by sibnerian