Options
All
  • Public
  • Public/Protected
  • All
Menu

promisify-electron-ipc

promisify-electron-ipc

Build Status Coveralls github devDependency Status npm

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

Generated using TypeDoc