Skip to content

Latest commit

 

History

History
187 lines (140 loc) · 5.15 KB

module.md

File metadata and controls

187 lines (140 loc) · 5.15 KB

Classes

Module

Functions

send(event, [...data])

Sends an IPC event with data.

fetch(event, timeout, ...args)Promise

Fetches some data from renderer process by sending an IPC event and waiting for a response. Returns a promise that resolves when the response is received.

call(event, ...args)Promise

Module.fetch without the need to provide a timeout value.

setDefaultFetchTimeout(timeout)

Sets the default fetch timeout.

respond(event, fetchId, [...data])

Sends and IPC event response for a provided fetch id.

on(event, callback)

Registers a callback to a IPC event.

removeListener(module, event, callback)

Unregisters a callback.

removeAllListeners(module, event)

Unregisters all callbacks.

once(event, callback, response)

Registers a once fired callback to a IPC event.

sendGlobal(event, [...data])

Sends a plain IPC event without namespacing it.

Module

Kind: global class

new Module()

Simple abstraction over electron's IPC. Ensures modules will not conflict with each other by providing events namespace. It is also a security layer as it is the only communication channel between your app and node environment.

send(event, [...data])

Sends an IPC event with data.

Kind: global function
Access: public

Param Type Description
event string event name
[...data] * data to send with the event

fetch(event, timeout, ...args) ⇒ Promise

Fetches some data from renderer process by sending an IPC event and waiting for a response. Returns a promise that resolves when the response is received.

Kind: global function
Access: public

Param Type Description
event string name of an event
timeout number how long to wait for the response in milliseconds
...args * arguments to send with the event

call(event, ...args) ⇒ Promise

Module.fetch without the need to provide a timeout value.

Kind: global function
Access: public

Param Type Description
event string name of an event
...args * arguments to send with the event

setDefaultFetchTimeout(timeout)

Sets the default fetch timeout.

Kind: global function

Param Type
timeout number

respond(event, fetchId, [...data])

Sends and IPC event response for a provided fetch id.

Kind: global function
Access: public

Param Type Description
event string event name
fetchId number fetch id that came with then event you are responding to
[...data] * data to send with the event

on(event, callback)

Registers a callback to a IPC event.

Kind: global function
Access: public

Param Type Description
event string event name
callback function callback to fire

removeListener(module, event, callback)

Unregisters a callback.

Kind: global function
Access: public

Param Type Description
module string module name
event string name of an event
callback function listener to unregister

removeAllListeners(module, event)

Unregisters all callbacks.

Kind: global function
Access: public

Param Type Description
module string module name
event string name of an event

once(event, callback, response)

Registers a once fired callback to a IPC event.

Kind: global function
Access: public

Param Type Description
event string event name
callback function callback to fire
response boolean whether we are listening for fetch response

sendGlobal(event, [...data])

Sends a plain IPC event without namespacing it.

Kind: global function
Access: public

Param Type Description
event string event name
[...data] * data to send with the event