Skip to content

Latest commit

 

History

History
271 lines (202 loc) · 8.08 KB

desktop.md

File metadata and controls

271 lines (202 loc) · 8.08 KB

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

Param Type Description
absolutePath string absolute 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

Param Type Description
assetPath string file 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

Param Type Description
absolutePath string absolute 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

Param Type Description
assetPath string file path relative to assets directory

on(module, event, callback)

Invokes callback when the specified IPC event is fired.

Kind: global function
Access: public

Param Type Description
module string module name
event string name of an event
callback ipcListener function 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

Param Type Default Description
module string module name
event string name of an event
callback ipcListener function to invoke when event is triggered
response boolean false whether we are listening for fetch response

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

send(module, event, ...args)

Send an event to the main Electron process.

Kind: global function
Access: public

Param Type Description
module string module name
event string name 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

Param Type Description
module string module name
event string event name
fetchId number fetch 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

Param Type Description
module string module name
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(module, event, ...args) ⇒ Promise

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

Kind: global function
Access: public

Param Type Description
module string module name
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

sendGlobal(...args)

Send an global event to the main Electron process.

Kind: global function
Access: public

Param Type Description
...args * arguments to the ipc.send(event, arg1, arg2)

ipcListener : function

Callback passed to ipc on/once methods.

Kind: global typedef

Param Type Description
event string event name
[...args] * event's arguments