ipc use as Promises
$ npm install ipc-promise
var ipcPromise = require('ipc-promise');
ipcPromise.on('twice', function(params) {
return Promise.resolve(params.value * 2);
});
var electron = require('electron'),
app = electron.app,
BrowserWindow = electron.BrowserWindow,
mainWindow;
app.on('ready', function() {
mainWindow = new BrowserWindow({});
mainWindow.loadURL('file://' + __dirname + '/index.html');
});
<!DOCTYPE html>
<script src="ipc-promise.min.js"></script>
<script>
ipcPromise
.send('twice', {
value: 1
})
.then(function(result) {
console.log(result); // => "2"
});
</script>
event
String
- event name
listener
Function(*): Promise
- listener function
listen event.
event
String
- event name
data
*
- data for send
return
Promise
- Promises
trigger event.
$ npm install
$ npm test
The MIT license. Please see LICENSE file.