From 7f5364f98dd8d0b0baf4d6530ac23dbb5e2634df Mon Sep 17 00:00:00 2001 From: Russell Carpenella Date: Wed, 3 May 2023 08:52:02 -0400 Subject: [PATCH] docs: moves icpMain.handle call in tutorial part 3 (#38138) --- docs/tutorial/tutorial-3-preload.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/tutorial-3-preload.md b/docs/tutorial/tutorial-3-preload.md index 97c45780e354..2074d3c5152c 100644 --- a/docs/tutorial/tutorial-3-preload.md +++ b/docs/tutorial/tutorial-3-preload.md @@ -202,7 +202,7 @@ Then, set up your `handle` listener in the main process. We do this _before_ loading the HTML file so that the handler is guaranteed to be ready before you send out the `invoke` call from the renderer. -```js {1,12} title="main.js" +```js {1,15} title="main.js" const { app, BrowserWindow, ipcMain } = require('electron') const path = require('path') @@ -214,10 +214,12 @@ const createWindow = () => { preload: path.join(__dirname, 'preload.js'), }, }) - ipcMain.handle('ping', () => 'pong') win.loadFile('index.html') } -app.whenReady().then(createWindow) +app.whenReady().then(() => { + ipcMain.handle('ping', () => 'pong') + createWindow() +}) ``` Once you have the sender and receiver set up, you can now send messages from the renderer