desktop.md

May 24, 2018 · View on GitHub

Classes

Desktop

Functions

getFileUrl(absolutePath)string

Just a convenience method for getting an url for a file from the local file system.

getAssetUrl(assetPath)string

Just a convenience method for getting an url for a file from the assets directory.

fetchFile(absolutePath)Promise

Just a convenience method for getting a file from the local file system. Returns a promise from fetch.

fetchAsset(assetPath)Promise

Just a convenience method for getting a file from the assets directory. Returns a promise from fetch.

on(module, event, callback)

Invokes callback when the specified IPC event is fired.

once(module, event, callback, response)

Invokes a callback once when the specified IPC event is fired.

removeListener(module, event, callback)

Unregisters a callback.

removeAllListeners(module, event)

Unregisters all callbacks.

send(module, event, ...args)

Send an event to the main Electron process.

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

Sends and IPC event response for a provided fetch id.

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

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

call(module, event, ...args)Promise

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

setDefaultFetchTimeout(timeout)

Sets the default fetch timeout.

sendGlobal(...args)

Send an global event to the main Electron process.

Typedefs

ipcListener : function

Callback passed to ipc on/once methods.

Desktop

Kind: global class

new Desktop()

Simple abstraction over electron's IPC. Securely wraps ipcRenderer. Available as Desktop global.

getFileUrl(absolutePath) ⇒ string

Just a convenience method for getting an url for a file from the local file system.

Kind: global function

ParamTypeDescription
absolutePathstringabsolute path to the file

getAssetUrl(assetPath) ⇒ string

Just a convenience method for getting an url for a file from the assets directory.

Kind: global function

ParamTypeDescription
assetPathstringfile path relative to assets directory

fetchFile(absolutePath) ⇒ Promise

Just a convenience method for getting a file from the local file system. Returns a promise from fetch.

Kind: global function

ParamTypeDescription
absolutePathstringabsolute path to the file

fetchAsset(assetPath) ⇒ Promise

Just a convenience method for getting a file from the assets directory. Returns a promise from fetch.

Kind: global function

ParamTypeDescription
assetPathstringfile path relative to assets directory

on(module, event, callback)

Invokes callback when the specified IPC event is fired.

Kind: global function
Access: public

ParamTypeDescription
modulestringmodule name
eventstringname of an event
callbackipcListenerfunction to invoke when event is triggered

once(module, event, callback, response)

Invokes a callback once when the specified IPC event is fired.

Kind: global function
Access: public

ParamTypeDefaultDescription
modulestringmodule name
eventstringname of an event
callbackipcListenerfunction to invoke when event is triggered
responsebooleanfalsewhether we are listening for fetch response

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

send(module, event, ...args)

Send an event to the main Electron process.

Kind: global function
Access: public

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

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

Sends and IPC event response for a provided fetch id.

Kind: global function
Access: public

ParamTypeDescription
modulestringmodule name
eventstringevent name
fetchIdnumberfetch id that came with then event you are responding to
[...data]*data to send with the event

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

Fetches some data from main 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
modulestringmodule name
eventstringname of an event
timeoutnumberhow long to wait for the response in milliseconds
...args*arguments to send with the event

call(module, event, ...args) ⇒ Promise

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

Kind: global function
Access: public

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

setDefaultFetchTimeout(timeout)

Sets the default fetch timeout.

Kind: global function

ParamType
timeoutnumber

sendGlobal(...args)

Send an global event to the main Electron process.

Kind: global function
Access: public

ParamTypeDescription
...args*arguments to the ipc.send(event, arg1, arg2)

ipcListener : function

Callback passed to ipc on/once methods.

Kind: global typedef

ParamTypeDescription
eventstringevent name
[...args]*event's arguments