I have to use few electron power events and usb-detection in our app and also communicate these events to the angular side.
Earlier with electron version 8, we used the ngx-electron in the angular side and webContents on the electron side to send and receive events on both side. After the version update, ngx-electron doesn't work anymore. I tried using 'import { ipcRenderer } from 'electron';'
in angular side with webContents in the electron side, but doesn't seem to work.
this.MainWindow.webContents.send('event-name'); //electron side
ipcRenderer.on('event-name', this.function()); // angular side
There are no errors from the above code, but the events doesn't trigger at all.
Using contextBridge also is not an option as there are some conflicts between contextBridge and serialport package that we use for our project.
Also tried by using ipcMain which only works if the first event is initiated in the renderer side:
// electron side
ipcMain.on('ping', function(event) {
event.sender.send('pong');
})
//Angular side
this._ipc.on('pong', (event: Electron.IpcMessageEvent) => {
console.log('pong');
});
this._ipc.send('ping');
We explicitly want to initiate an event on the main side and receive in the angular side. Also vice versa, both are important for few use cases. Anyone else using ipc events with the latest electron and angular versions could help us with this?