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
Copy file name to clipboardExpand all lines: docs/api/ipc-renderer.md
+42-4Lines changed: 42 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ Removes all listeners, or those of the specified `channel`.
57
57
58
58
Send an asynchronous message to the main process via `channel`, along with
59
59
arguments. Arguments will be serialized with the [Structured Clone
60
-
Algorithm][SCA], just like [`postMessage`][], so prototype chains will not be
60
+
Algorithm][SCA], just like [`window.postMessage`][], so prototype chains will not be
61
61
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
62
62
throw an exception.
63
63
@@ -68,6 +68,10 @@ throw an exception.
68
68
The main process handles it by listening for `channel` with the
69
69
[`ipcMain`](ipc-main.md) module.
70
70
71
+
If you need to transfer a [`MessagePort`][] to the main process, use [`ipcRenderer.postMessage`](#ipcrendererpostmessagechannel-message-transfer).
72
+
73
+
If you want to receive a single response from the main process, like the result of a method call, consider using [`ipcRenderer.invoke`](#ipcrendererinvokechannel-args).
74
+
71
75
### `ipcRenderer.invoke(channel, ...args)`
72
76
73
77
*`channel` String
@@ -77,7 +81,7 @@ Returns `Promise<any>` - Resolves with the response from the main process.
77
81
78
82
Send a message to the main process via `channel` and expect a result
79
83
asynchronously. Arguments will be serialized with the [Structured Clone
80
-
Algorithm][SCA], just like [`postMessage`][], so prototype chains will not be
84
+
Algorithm][SCA], just like [`window.postMessage`][], so prototype chains will not be
81
85
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
Copy file name to clipboardExpand all lines: docs/api/structures/ipc-main-event.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
*`frameId` Integer - The ID of the renderer frame that sent this message
4
4
*`returnValue` any - Set this to the value to be returned in a synchronous message
5
5
*`sender` WebContents - Returns the `webContents` that sent the message
6
+
*`ports` MessagePortMain[] - A list of MessagePorts that were transferred with this message
6
7
*`reply` Function - A function that will send an IPC message to the renderer frame that sent the original message that you are currently handling. You should use this method to "reply" to the sent message in order to guarantee the reply will go to the correct process and frame.
Copy file name to clipboardExpand all lines: docs/api/structures/ipc-renderer-event.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,5 +2,6 @@
2
2
3
3
*`sender` IpcRenderer - The `IpcRenderer` instance that emitted the event originally
4
4
*`senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`.
5
+
*`ports` MessagePort[] - A list of MessagePorts that were transferred with this message
0 commit comments