Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 months 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-22T15:01:53.000Z (almost 6 years ago)
- Last Synced: 2024-10-31T16:57:06.521Z (3 months ago)
- Topics: electron, ipc, rpc
- Language: JavaScript
- Size: 43.9 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-ipc-rpc
[![NPM version](https://badge.fury.io/js/electron-ipc-rpc.svg)](http://badge.fury.io/js/electron-ipc-rpc)
[![dependencies Status](https://david-dm.org/hobbyquaker/electron-ipc-rpc/status.svg)](https://david-dm.org/hobbyquaker/electron-ipc-rpc)
[![Build Status](https://travis-ci.org/hobbyquaker/electron-ipc-rpc.svg?branch=master)](https://travis-ci.org/hobbyquaker/electron-ipc-rpc)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](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