Skip to content
Library to use promises for inter-process communication for electron.
TypeScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
test
.gitignore
.prettierrc
.travis.yml
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

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

You can’t perform that action at this time.