Cannot receive message sent from main process to renderer process in Electron

Viewed 11642

I'm sending a message from the main to the renderer process.

In the main process, I'm doing this:

const ipcMain = require('electron').ipcMain;

ipcMain.on('asynchronous-message', function(event, arg) {
   console.log('m i here');
   event.sender.send('asynchronous-reply', 'pong');
});

In the renderer script, I'm doing this:

const ipcRenderer = require('electron').ipcRenderer;

ipcRenderer.on('asynchronous-reply', function(event, arg) {
    console.log('In renderer again');
});

However, it seems like the message is not received in the renderer process. What am I missing?

3 Answers
Related