Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda