docs: moves icpMain.handle call in tutorial part 3 (#38138)
This commit is contained in:
parent
a8c0ed890f
commit
7f5364f98d
1 changed files with 5 additions and 3 deletions
|
@ -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
|
loading the HTML file so that the handler is guaranteed to be ready before
|
||||||
you send out the `invoke` call from the renderer.
|
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 { app, BrowserWindow, ipcMain } = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
|
@ -214,10 +214,12 @@ const createWindow = () => {
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
ipcMain.handle('ping', () => 'pong')
|
|
||||||
win.loadFile('index.html')
|
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
|
Once you have the sender and receiver set up, you can now send messages from the renderer
|
||||||
|
|
Loading…
Reference in a new issue