docs: moves icpMain.handle call in tutorial part 3 (#38175)

docs: moves icpMain.handle call in tutorial part 3 (#38138)

Co-authored-by: Russell Carpenella <russellcarpenella@gmail.com>
This commit is contained in:
David Sanders
2023-05-04 03:25:50 -07:00
committed by GitHub
parent dd59115ac6
commit 320415edf9

View File

@@ -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