module.md

May 24, 2018 · View on GitHub

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

ParamTypeDescription
eventstringevent 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

ParamTypeDescription
eventstringname of an event
timeoutnumberhow 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

ParamTypeDescription
eventstringname of an event
...args*arguments to send with the event

setDefaultFetchTimeout(timeout)

Sets the default fetch timeout.

Kind: global function

ParamType
timeoutnumber

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

Sends and IPC event response for a provided fetch id.

Kind: global function
Access: public

ParamTypeDescription
eventstringevent name
fetchIdnumberfetch 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

ParamTypeDescription
eventstringevent name
callbackfunctioncallback to fire

removeListener(module, event, callback)

Unregisters a callback.

Kind: global function
Access: public

ParamTypeDescription
modulestringmodule name
eventstringname of an event
callbackfunctionlistener to unregister

removeAllListeners(module, event)

Unregisters all callbacks.

Kind: global function
Access: public

ParamTypeDescription
modulestringmodule name
eventstringname of an event

once(event, callback, response)

Registers a once fired callback to a IPC event.

Kind: global function
Access: public

ParamTypeDescription
eventstringevent name
callbackfunctioncallback to fire
responsebooleanwhether we are listening for fetch response

sendGlobal(event, [...data])

Sends a plain IPC event without namespacing it.

Kind: global function
Access: public

ParamTypeDescription
eventstringevent name
[...data]*data to send with the event