new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Electron · API · all subjects

app/ipc

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

IpcMainServiceWorkerInvokeEvent structure properties

IpcMainServiceWorkerInvokeEvent object extends Event and has the following properties: type (String, possible values include 'service-worker'), serviceWorker (ServiceWorkerMain, readonly, the service worker that sent the message), versionId (Number, the service worker version ID), and session (Session instance with which the event is associated).

frame.send() method

frame.send(channel, ...args) sends an asynchronous message to the renderer process via channel, along with arguments. Arguments will be serialized with the Structured Clone Algorithm, just like postMessage, so prototype chains will not be included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception. The renderer process can handle the message by listening to channel with the ipcRenderer module.

frame.postMessage() example with MessagePortMain

Example showing how to send a message with transferred MessagePortMain objects: ```js // Main process const win = new BrowserWindow() const { port1, port2 } = new MessageChannelMain() win.webContents.mainFrame.postMessage('port', { message: 'hello' }, [port1]) // Renderer process ipcRenderer.on('port', (e, msg) => { const [port] = e.ports // ... }) ```

webview.send(channel, ...args) method

Parameters: channel (string), ...args (any[]). Returns Promise<void>. Sends an asynchronous message to renderer process via channel, you can also send arbitrary arguments. The renderer process can handle the message by listening to the channel event with the ipcRenderer module.

webview.sendToFrame(frameId, channel, ...args) method

Parameters: frameId ([number, number] - [processId, frameId]), channel (string), ...args (any[]). Returns Promise<void>. Sends an asynchronous message to renderer process via channel, you can also send arbitrary arguments. The renderer process can handle the message by listening to the channel event with the ipcRenderer module.

webview ipc-message event

Event fired when the guest page has sent an asynchronous message to embedder page. Returns: frameId ([number, number] - pair of [processId, frameId]), channel (string), args (any[]).

webview example ipc-message with send and sendToHost

Example showing bidirectional communication between embedder and guest page. Embedder page: const webview = document.querySelector('webview'); webview.addEventListener('ipc-message', (event) => { console.log(event.channel); // Prints "pong" }); webview.send('ping'); Guest page: const { ipcRenderer } = require('electron'); ipcRenderer.on('ping', () => { ipcRenderer.sendToHost('pong'); });

Give your agent this brain