electron/docs/api/ipc-renderer.md

30 lines
1.2 KiB
Markdown
Raw Normal View History

2013-09-09 07:35:57 +00:00
# ipc (renderer)
2013-08-14 22:43:35 +00:00
The `ipc` module provides a few methods so you can send synchronous and
asynchronous messages to the main process, and also receive messages sent from
main process. If you want to make use of modules of main process from renderer
process, you might consider using the [remote](remote.md) module.
2013-08-14 22:43:35 +00:00
See [ipc (main process)](ipc-main-process.md) for examples.
2013-08-14 22:43:35 +00:00
2014-04-25 09:35:36 +00:00
## ipc.send(channel[, args...])
2013-08-14 22:43:35 +00:00
Send `args..` to the renderer via `channel` in asynchronous message, the main
2014-04-25 09:35:36 +00:00
process can handle it by listening to the `channel` event of `ipc` module.
2013-08-14 22:43:35 +00:00
2014-04-25 09:35:36 +00:00
## ipc.sendSync(channel[, args...])
2013-08-14 22:43:35 +00:00
Send `args..` to the renderer via `channel` in synchronous message, and returns
the result sent from main process. The main process can handle it by listening to
2014-04-25 09:35:36 +00:00
the `channel` event of `ipc` module, and returns by setting `event.returnValue`.
2013-08-14 22:43:35 +00:00
**Note:** Usually developers should never use this API, since sending
synchronous message would block the whole renderer process.
2014-12-17 19:09:11 +00:00
## ipc.sendToHost(channel[, args...])
Like `ipc.send` but the message will be sent to the host page instead of the
main process.
2014-12-17 19:09:11 +00:00
This is mainly used by the page in `<webview>` to communicate with host page.