diff --git a/docs/api/message-channel-main.md b/docs/api/message-channel-main.md index b9ddc9036cbe..3d354bcc02cd 100644 --- a/docs/api/message-channel-main.md +++ b/docs/api/message-channel-main.md @@ -13,9 +13,19 @@ Process: [Main](../glossary.md#main-process) Example: ```js +// Main process const { port1, port2 } = new MessageChannelMain() w.webContents.postMessage('port', null, [port2]) port1.postMessage({ some: 'message' }) + +// Renderer process +const { ipcRenderer } = require('electron') +ipcRenderer.on('port', (e) => { + // e.ports is a list of ports sent along with this message + e.ports[0].on('message', (messageEvent) => { + console.log(messageEvent.data) + }) +}) ``` ### Instance Properties