https://github.com/d0mih/promisify-electron-ipc
Library to use promises for inter-process communication for electron.
https://github.com/d0mih/promisify-electron-ipc
electron electron-module ipc ipc-message nodejs npm-package promises
Last synced: 4 months ago
JSON representation
Library to use promises for inter-process communication for electron.
- Host: GitHub
- URL: https://github.com/d0mih/promisify-electron-ipc
- Owner: D0miH
- License: mit
- Created: 2019-03-31T15:08:40.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T17:23:59.000Z (over 3 years ago)
- Last Synced: 2025-09-09T05:18:13.369Z (9 months ago)
- Topics: electron, electron-module, ipc, ipc-message, nodejs, npm-package, promises
- Language: TypeScript
- Size: 985 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promisify-electron-ipc
[](https://travis-ci.org/D0miH/promisify-electron-ipc)  [](https://david-dm.org/D0miH/promisify-electron-ipc#info=devDependencies) [](https://www.npmjs.com/package/promisify-electron-ipc)
### Library to easily use promises for inter-process communication in electron.
## Installation
```sh
npm install promisify-electron-ipc
```
or
```sh
yarn add promisify-electron-ipc
```
## Documentation
You can find the documentation [here](https://d0mih.github.io/promisify-electron-ipc/).
## Usage
Sending messages from the renderer to the main process:
```javascript
// In the main process
import { promiseIpcMain } from "promisify-electron-ipc";
promiseIpcMain.on("greet-channel", name => {
return Promise.resolve("Hello " + name);
});
```
```javascript
// 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:
```javascript
// In the main process
import { promiseIpcMain } from "promisify-electron-ipc";
promiseIpcMain
.send("greet-channel", win.webContents, "Bob")
.then(answer => console.log(answer));
```
```javascript
// 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](https://github.com/sibnerian/electron-promise-ipc)