You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This Api is very similar - if not exactly the same - as Electrons MessageChannelMain, however currently both have limitations:
Property
MessageChannel
MessageChannelMain
Port can be transferred to BrowserWindow
no
yes
Port can be transferred to Worker Thread
yes
no
Port can be transferred to Child Process
no
no
Proposed Solution
The proposed solution would be to support Node's native MessageChannel Api, specifically being able to transfer a MessagePort from/to Browser Windows. MessageChannelMain could be deprecated/removed.
Having just one api will greatly simplify development of electron applications:
// Main processconst{ port1, port2 }=newMessageChannel()w.webContents.postMessage('port',null,[port2])constworker=newWorker("./worker.js");worker.postMessage(port1,[port1]);// Renderer processconst{ ipcRenderer }=require('electron')ipcRenderer.on('port',(e)=>{constport2=e.ports[0]port2.postMessage({message: 'ping'})// communicate directly with Worker Process})// Worker Processport1.postMessage({message: 'pong'})// communicate directly with BrowserWindow
Property
MessageChannel
Port can be transferred to Browser Window
yes
Port can be transferred to Worker Thread
yes
Port can be transferred to Child Process
no
Alternatives Considered
None
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Preflight Checklist
Problem Description
For some time now, Node has had the MessageChannel Api.
This Api is very similar - if not exactly the same - as Electrons MessageChannelMain, however currently both have limitations:
Proposed Solution
The proposed solution would be to support Node's native
MessageChannel
Api, specifically being able to transfer aMessagePort
from/to Browser Windows.MessageChannelMain
could be deprecated/removed.Having just one api will greatly simplify development of electron applications:
Alternatives Considered
None
Additional Information
No response
The text was updated successfully, but these errors were encountered: