@@ -89,13 +89,10 @@ ipc.answerMain('get-emoji', async emojiName => {
89
89
###### Main
90
90
91
91
``` js
92
- const electron = require (' electron' );
93
92
const {ipcMain: ipc } = require (' electron-better-ipc' );
94
93
95
- const browserWindow = electron .BrowserWindow .getFocusedWindow ();
96
-
97
94
(async () => {
98
- const emoji = await ipc .callRenderer (browserWindow, ' get-emoji' , ' unicorn' );
95
+ const emoji = await ipc .callFocusedRenderer ( ' get-emoji' , ' unicorn' );
99
96
console .log (emoji);
100
97
// => '🦄'
101
98
})();
@@ -114,7 +111,7 @@ Send a message to the given window.
114
111
115
112
In the renderer process, use ` ipcRenderer.answerMain ` to reply to this message.
116
113
117
- Returns a ` Promise<unknown> ` with the reply from the renderer process..
114
+ Returns a ` Promise<unknown> ` with the reply from the renderer process.
118
115
119
116
#### browserWindow
120
117
@@ -134,6 +131,26 @@ Type: `unknown`
134
131
135
132
The data to send to the receiver.
136
133
134
+ ### ipcMain.callFocusedRenderer(channel, [ data] )
135
+
136
+ Send a message to the focused window, as determined by ` electron.BrowserWindow.getFocusedWindow ` .
137
+
138
+ In the renderer process, use ` ipcRenderer.answerMain ` to reply to this message.
139
+
140
+ Returns a ` Promise<unknown> ` with the reply from the renderer process.
141
+
142
+ #### channel
143
+
144
+ Type: ` string `
145
+
146
+ The channel to send the message on.
147
+
148
+ #### data
149
+
150
+ Type: ` unknown `
151
+
152
+ The data to send to the receiver.
153
+
137
154
### ipcMain.answerRenderer(channel, callback)
138
155
139
156
This method listens for a message from ` ipcRenderer.callMain ` defined in a renderer process and replies back.
0 commit comments