'Is there a reason they put the "ipcMain.on" event listener inside the createWindow() function?

Reading through the electron js docs at the moment and on the IPC page, pattern 1(https://www.electronjs.org/docs/latest/tutorial/ipc#pattern-1-renderer-to-main-one-way) they gave a code example. Inside main.js they put the event listener inside the createWindow() function and I don't see any reason why. I tried putting it outside and it just works fine. And considerations on that? Am I missing something?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source