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

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

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 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