Electron | Error invoking remote method 'some-name'

3.5k views Asked by At

I'm trying to implement in my electron application.

In main.ts :

  ipcMain.handle('some-name', async (event, someArgument) => {
    console.log("--------------------")
    console.log(someArgument)
    console.log("--------------------")
    return true
  })

In a React.Component, I got :

import { ipcRenderer } from 'electron'
...
ipcRenderer.invoke('some-name',"sadkjasd").then((result) => {
      console.log("finished")
    })

And it's giving me error, saying :

Uncaught (in promise) Error: Error invoking remote method 'some-name': No handler registered for 'some-name'
    at EventEmitter.o.invoke (electron/js2c/renderer_init.js:71)

How can I register an event ?

I'm actually trying to figure out IPC of GitHub desktop, that's one cool electron app :

0

There are 0 answers