🎯 A Better Promise based IPC Library in Electron
- Promise based API, write with
async / await
simply - Send a message and get the response back in the same call
- Same Api in Renderer and Main Process, Electron-compatible api design
- Always send to all browserWindows from main process, forget the webContents
- Keep the raw event object just in case
- Work fine with electron-builder (no peerDependencies limit)
$ npm install electron-promise-extra --save
// in renderer or main process
import ipc from 'electron-ipc-extra'
ipc.on('channel-name', async (...args) => {
await getSomeData()
return 'reply data'
})
// in main or renderer process
import ipc from 'electron-ipc-extra'
let data = await ipc.send('channel-name', 'some data', 'another data')
console.log('data') // => 'reply data'
ipc.on('ondragstart', async function(...args) {
var { event } = this
event.sender.startDrag({
file: 'some file',
icon: 'some native image'
})
return 'reply data'
})
import ipc from 'electron-ipc-extra'
ipc.off('channel-name')
Install Devtron
MIT