Dmitry Shnyrev
Dmitry Shnyrev

Reputation: 76

How to call some logic in Electron application from outside?

I plan to write my Electron app, but I still don't have any ideas how to implement such use case - How to call some logic in Electron application from outside?

For example, there is a real application MavensMate. I can run it and leave in tray, and next from Sublime text menu I can run different logic inside MavensMate.

Upvotes: 1

Views: 256

Answers (1)

Dmitry Shnyrev
Dmitry Shnyrev

Reputation: 76

I found solution:

  1. In Electron app start ExpressJS server (from mainProcess)

  2. In ExpressJS request handler add

    win.webContents.send('superEvent', 'ping');
    
  3. In rendererProcess add

    ipcRenderer.on('superEvent', (event, arg) => {alert('pong')});
    
  4. Start Electon app, open ExpressJS page in Browser and you will see alert in Electron window. Profit! :)

Upvotes: 1

Related Questions