How to use the electron-better-ipc.ipcMain.on function in electron-better-ipc

To help you get started, we’ve selected a few electron-better-ipc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wulkano / kap / main / export-list.js View on Github external
}
}

let exportList;

ipc.answerRenderer('get-exports', () => exportList.getExports());

ipc.answerRenderer('export', options => exportList.addExport(options));

ipc.answerRenderer('cancel-export', createdAt => exportList.cancelExport(createdAt));

ipc.answerRenderer('open-export', createdAt => exportList.openExport(createdAt));

ipc.answerRenderer('export-snapshot', saveSnapshot);

ipc.on('drag-export', async (event, createdAt) => {
  const exportItem = exportList.getExport(createdAt);
  const file = exportItem && exportItem.data.filePath;

  if (file && fs.existsSync(file)) {
    event.sender.startDrag({
      file,
      icon: await getDragIcon(exportItem.imagePath)
    });
  }
});

const callExportsWindow = (channel, data) => {
  const exportsWindow = getExportsWindow();

  if (exportsWindow) {
    // TODO(karaggeorge): Investigate why `ipc.callRenderer(exportsWindow, channel, data);` is not working here.
github npezza93 / archipelago / app / main / pty.js View on Github external
created(sessionId, sessionWindowId) {
    this.sessionId = sessionId
    this.sessionWindow = BrowserWindow.getAllWindows().find(browserWindow => {
      return browserWindow.id === sessionWindowId
    })
    ipc.on(`pty-resize-${this.sessionId}`, this.handleResize.bind(this))
    ipc.on(`pty-write-${this.sessionId}`, this.handleWrite.bind(this))
    this.pty.onExit(() => {
      this.sessionWindow.webContents.send(`pty-exit-${this.sessionId}`)
    })
    this.pty.onData(data => this.bufferData(data))
  }
github npezza93 / archipelago / app / main / windows / visor.js View on Github external
export default profileManager => {
  const enableShortcuts = () => register(profileManager)
  const disableShortcuts = () => globalShortcut.unregisterAll()

  subscriptions.add(
    profileManager.onDidChange('visor.keybinding', () => {
      disableShortcuts()
      enableShortcuts()
    })
  )

  ipc.on('disable-shortcuts', disableShortcuts)
  subscriptions.add(
    new Disposable(() => ipc.removeListener('disable-shortcuts', disableShortcuts))
  )
  ipc.on('enable-shortcuts', enableShortcuts)
  subscriptions.add(
    new Disposable(() => ipc.removeListener('enable-shortcuts', enableShortcuts))
  )

  enableShortcuts()
}
github npezza93 / archipelago / app / main / windows / visor.js View on Github external
export default profileManager => {
  const enableShortcuts = () => register(profileManager)
  const disableShortcuts = () => globalShortcut.unregisterAll()

  subscriptions.add(
    profileManager.onDidChange('visor.keybinding', () => {
      disableShortcuts()
      enableShortcuts()
    })
  )

  ipc.on('disable-shortcuts', disableShortcuts)
  subscriptions.add(
    new Disposable(() => ipc.removeListener('disable-shortcuts', disableShortcuts))
  )
  ipc.on('enable-shortcuts', enableShortcuts)
  subscriptions.add(
    new Disposable(() => ipc.removeListener('enable-shortcuts', enableShortcuts))
  )

  enableShortcuts()
}