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

225
Visualizações
How to send setup information in electron to a renderer process when creating it?

I am making an electron app in which I am using a class to create instances of Renderer windows (I need multiple instances of the renderer). Each renderer window has to be connected to a specific data set.

The problem is, I can't see an obvious way in Electron to pass setup values to the renderer process when I set it up in the Main process. I am using the createWindow function and I don't see any way to connect any variable or object to it which can be recovered in the preload or the renderer Javascript file.

How do people typically handle that?

To illustrate further what I want to do.

  • Open dataset #1 in new window
  • Open dataset #2 in another window
  • Let people check and compare and then save data.

How do I pass the dataset info to the new window when I use the createWindow command to create it?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Send each BrowserWindow their data like this:

// Main process.

win.webContents.send('data', {'a': 'b'... });

Recieve the data like this:

// Renderer process.

var ipcRenderer = require('electron').ipcRenderer;

ipcRenderer.on('data', function(evt, data) {
    console.log(data); // {'a': 'b'}
});

See it from the documentation.

about 4 years ago · Juan Pablo Isaza Relatório

0

I found that if I created a renderer and had the main process send a message immediately, the message would sometimes be lost. So I have found it necessary to wait for the 'did-finish-load' event first.

  //main
  const createWindow = (windowData) => {
    let win = new BrowserWindow({
      show: false,
    });
    win.loadFile(path.join(__dirname, 'index.html'))
    win.webContents.once('did-finish-load', () => {
      win.webContents.send('doThing', windowData)
    })
  }
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