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

message channels

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

Utility process message channel with renderer

The primary difference between the utility process and process spawned by Node.js child_process module is that the utility process can establish a communication channel with a renderer process using MessagePorts.

contents.postMessage(channel, message, transfer) - post message with ports

Send a message to the renderer process, optionally transferring ownership of zero or more MessagePortMain objects. The transferred MessagePortMain objects will be available in the renderer process by accessing the ports property of the emitted event. When they arrive in the renderer, they will be native DOM MessagePort objects. Parameters: channel (string), message (any), transfer (MessagePortMain[], optional).

postMessage() example

// Main process const win = new BrowserWindow() const { port1, port2 } = new MessageChannelMain() win.webContents.postMessage('port', { message: 'hello' }, [port1]) // Renderer process ipcRenderer.on('port', (e, msg) => { const [port] = e.ports // ... })

Give your agent this brain