electron/docs/api/renderer/ipc-renderer.md

23 lines
945 B
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 browser, and also receive messages sent from
browser. If you want to make use of modules of browser from renderer, you
might consider using the [remote](remote.md) module.
2013-08-14 22:43:35 +00:00
2014-04-25 09:35:36 +00:00
See [ipc (browser)](../browser/ipc-browser.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
2014-04-25 09:35:36 +00:00
Send `args..` to the web page via `channel` in asynchronous message, the browser
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
2014-04-25 09:35:36 +00:00
Send `args..` to the web page via `channel` in synchronous message, and returns
the result sent from browser. The browser process can handle it by listening to
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
2014-04-25 09:35:36 +00:00
synchronous message would block the whole web page.