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

191
Views
Electron: How to pass the message/data from preload to renderer?

Basicly I want the renderer to constantly listen for the message from and preload can send the message to renderer anytime. Basicly my scenario is:

  1. Whenever user copies anything to clipboard, the main process will send the message to preload via webContents.send("clipboard-updated");
  2. Main process will save the newly received clip into the database.
  3. Preload will send the message to the renderer upon receiving the message from the main.
  4. Render will fetch the data from the database again and will refresh the UI. this is the whole scenario and here I'm unable to figure out that how do I send the message to renderer so that it can refresh the UI.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use Window.postMessage() to send data from preload to renderer

// preload

window.postMessage("your-data", "*");
// renderer

window.addEventListener("message", (event) => {
  // event.source === window means the message is coming from the preload
  // script, as opposed to from an <iframe> or other source.
  if (event.source === window) {
    console.log("from preload:", event.data);
  }
});

Or you can communicate directly from the main process to the renderer process AKA "main world" as seen here in the docs

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!