Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It does not need to be included in the createWindow() function scope. That is just the way the person wrote it in the Doc’s. In an attempt to keep it simple, I suspect they did not want to add an unnecessary number of files to the example. Instead, they sacrificed code separation for simplicity in understanding.

As your code base matures, code such as that shown in Pattern 1: Render to main (one-way) could be refactored by moving the ipcMain.on('set-title', () => { ... }) function into a script that handles the setting / rendering of the applications window frame.

Remember, most if not all examples given in the Electron Doc’s and API's sections could be refactored as your application grows, allowing for better separation of concerns and code readability.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda