https://github.com/hobbyquaker/electron-ipc-rpc
Simple and tiny RPC wrapper around electron ipc
https://github.com/hobbyquaker/electron-ipc-rpc
electron ipc rpc
Last synced: about 1 year ago
JSON representation
Simple and tiny RPC wrapper around electron ipc
- Host: GitHub
- URL: https://github.com/hobbyquaker/electron-ipc-rpc
- Owner: hobbyquaker
- License: mit
- Created: 2017-08-17T18:48:44.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-02-22T15:01:53.000Z (over 7 years ago)
- Last Synced: 2025-04-10T22:04:48.050Z (about 1 year ago)
- Topics: electron, ipc, rpc
- Language: JavaScript
- Size: 43.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-ipc-rpc
[](http://badge.fury.io/js/electron-ipc-rpc)
[](https://david-dm.org/hobbyquaker/electron-ipc-rpc)
[](https://travis-ci.org/hobbyquaker/electron-ipc-rpc)
[](https://github.com/sindresorhus/xo)
[![License][mit-badge]][mit-url]
> Simple and tiny RPC wrapper around electron ipc
#### Why?
I created this module because I wanted a more convenient drop-in replacement for socket.io when porting "classic" web
apps to electron.
## Usage
#### main
```javascript
const Rpc = require('electron-ipc-rpc');
const rpc = new Rpc(electron.ipcMain, mainWindow.webContents);
rpc.on('method2', (params, callback) => {
callback(null, 'method2 response!');
});
rpc.send('method1', [], (err, res) => {
console.log(res);
});
```
#### renderer
```javascript
const Rpc = require('electron-ipc-rpc');
const rpc = new Rpc(electron.ipcRenderer);
rpc.on('method1', (params, callback) => {
callback(null, 'method1 response');
});
rpc.send('method2', [], (err, res) => {
console.log(res);
});
```
#### Timeout
By default a method call times out after 30s without response. This can be changed by just overwriting `rpc.timeout`
with the desired millisecond value.
## License
MIT © [Sebastian Raff](https://github.com/hobbyquaker)
[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
[mit-url]: LICENSE