electron-ipc-rpc
v1.1.1
Published
Simple and tiny RPC wrapper around electron ipc
Downloads
4
Readme
electron-ipc-rpc
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
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
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