First run t ipc-r

This commit is contained in:
Jessica Lord 2015-08-26 17:56:10 -07:00
parent 71f46c0287
commit a1f17069ec

View file

@ -1,29 +1,41 @@
# ipc (renderer) # ipc (renderer)
The `ipc` module provides a few methods so you can send synchronous and 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 asynchronous messages from the render process (web page) to the main process. You can also receive messages returned from the main process.
main process. If you want to make use of modules of main process from renderer
**Note**: If you want to make use of modules in the main process from the renderer
process, you might consider using the [remote](remote.md) module. process, you might consider using the [remote](remote.md) module.
See [ipc (main process)](ipc-main-process.md) for examples. See [ipc (main process)](ipc-main-process.md) for code examples.
## ipc.send(channel[, args...]) ## Methods
Send `args..` to the renderer via `channel` in asynchronous message, the main The `ipc` module has the following methods for sending messages:
process can handle it by listening to the `channel` event of `ipc` module.
## ipc.sendSync(channel[, args...]) **Note**: When using these methods to send a `message` you must also listen for it in the main process with [`ipc (main process)`](ipc-main-process.md).
Send `args..` to the renderer via `channel` in synchronous message, and returns ### `ipc.send(channel[, message])`
the result sent from main process. The main process can handle it by listening to
the `channel` event of `ipc` module, and returns by setting `event.returnValue`.
**Note:** Usually developers should never use this API, since sending * `channel` String - The event name.
synchronous message would block the whole renderer process. * `message` (optional)
## ipc.sendToHost(channel[, args...]) Send a `message` (any type) to the main process asynchronously via a `channel`. The main process handles it by listening for the `channel` event with `ipc`.
Like `ipc.send` but the message will be sent to the host page instead of the ### `ipc.sendSync(channel[, message])`
main process.
This is mainly used by the page in `<webview>` to communicate with host page. * `channel` String - The event name.
* `message` (optional)
Send a `message` (any type) to the main process synchronously via a `channel`. A result is returned from the main process.
The main process handles it by listening for the `channel` event with `ipc` and replies by setting the `event.returnValue`.
**Note:** Sending a synchronous message will block the whole renderer process so
using this method is not recommended.
### `ipc.sendToHost(channel[, message])`
* `channel` String - The event name.
* `message` (optional)
Like `ipc.send` but the message will be sent to the host page in a `<webview>` instead of the main process.