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