#backend processes not in main.js

16 messages · Page 1 of 1 (latest)

next flicker
#

Hi everyone,
I have an electron app, which I need to implement serial communication, and run the function through ipc from the renderer. Should I implement the functions in main.js, or there is a better solution for it? For example in a 'utils.js' which i require in the main.js.
So the main question is that is recomended or not to handle all the backend/hardware processes in the main.js?

tranquil marsh
#

name of the file doesnt matter

next flicker
#

I know, i just wrote it for example. It bothers me to create a gigantic main.js file and i don't know if it should or not

tranquil marsh
#

you can split your code into multiple files

next flicker
#

but since the ipc comm. works between the main and the renderer I still whould have to call the functions from the main.js, right?

tranquil marsh
#

no

#

main is main process

#

not main.js file

next flicker
#

ohh, then if the ipcMain would be not in the main.js, where?

tranquil marsh
#

anywhere

next flicker
#

and how can i link that file to the main ?

tranquil marsh
#

with require()

next flicker
#

I tried this, but the main->renderer ipc doesn't work, because in the utils.js (which contains tha main->renderer ipc) the mainWindow is not defined .
"mainWindow.webContents.send('data-reply', someData); // Send data back to renderer"

tranquil marsh
#

then you should somehow pass that window

next flicker
#

thanks, i'm trying to figure it out. At least the renderer->main works

spice flicker