2.0.0 • Published 4 years ago

electron-ipc-extra v2.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

electron-ipc-extra

:dart: A Better Promise based IPC Library in Electron

Features

  • 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)

Installation

$ npm install electron-ipc-extra --save

Usage

// 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'

Main send to Webcontents

let data = await ipc.sendToWebContents(webContents, 'channel-name', 'data')

Get original event object

ipc.on('ondragstart', async function(...args) {
  var { event } = this
  event.sender.startDrag({
    file: 'some file',
    icon: 'some native image'
  })
  return 'reply data'
})

Removing Listeners

import ipc from 'electron-ipc-extra'

ipc.off('channel-name')

Debug IPC data

Install Devtron

npm.io

Reference Doc

License

MIT

2.0.0

4 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.2

5 years ago

1.0.0

5 years ago