How to integrate Electron ipcRenderer into Angular 2 app based on TypeScript?

前端 未结 6 1044
陌清茗
陌清茗 2020-12-23 15:10

I want to use ipcMain / ipcRenderer on my project to communicate from Angular to Electron and back.

The Electron side is pretty clear:

const
  electr         


        
6条回答
  •  萌比男神i
    2020-12-23 15:25

    This should just be a case of requiring the ipcRenderer module in your main html file (electron will provide this for you):

    
    

    and then setting up a handler in your main js file:

    const ipcMain = require('electron').ipcMain;
    ipcMain.on('getSomething', function(event, arg) {
      event.returnValue = 'something';
    });
    

    That's all there should be to it.

提交回复
热议问题