Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!