Send data from main process to renderer


#1

Hey! How to send data from main process to renderer process?
My main process getting data from websockets and processes it. Sometimes I need to send these data to renderer process and show.

Thanks!


#2

You use the ipcMain and ipcRenderer modules.


#3

I cant emit event from ipcMain like ipcRenderer.send(channel[, arg1][, arg2][, ...])
I this case I have to call ipcMain from renderer, but have no event in renderer to call ipcMain. Is there some function like ipcRenderer.send, but in ipcMain?


#4

You use ipcRenderer.send() to send data from the renderer process to the main process. Once the main process has a target, as demonstrated in the first example on the ipcMain documentation page, then you can send a signal back using the .send() method on that target.

If your app is only using one renderer process, then you can easily have it initialize a connection and have the main process store the resulting object somewhere that you can call it easily.