Skip to content

Latest commit

 

History

History
115 lines (83 loc) · 5.07 KB

mainapp.js.md

File metadata and controls

115 lines (83 loc) · 5.07 KB

mainapp

High-level functions for quickly building the main application.

event ⏏

Exports a node.js Event Emitter object that can be used to send and receive messages with other parts of the application.

Kind: Exported member
See: Events

setupAppConfig() ⏏

Must be called before other APIs. Reads the two configuration files, app-config.json and firebase-config.json, and creates a global.appContext object with various information.

Kind: Exported function

sendToBrowser(channel, payload) ⏏

Sends a message - a payload on a specific channel - to the global.mainWindow.

Kind: Exported function
See: BrowserWindow.webContents.send()

Param Type Description
channel string A topic which the BrowserWindow should be expecting
payload string | number | object | array The message content to send on the topic

getFromBrowser(channel, [callback]) ⇒ Promise.<(string|number|object|array)>

Receives a message event from the global.mainWindow, with optional callback or Promise interface. The callback or Promise will fire whenever a message event is received on the channel.

Kind: Exported function
Returns: Promise.<(string|number|object|array)> - If no callback is supplied then a Promise is returned
See: BrowserWindow.webContents.send()

Param Type Description
channel string A topic which the BrowserWindow should be expecting
[callback] function Optional callback function to receive the message event

closeApplication() ⏏

Call this before the app closes to perform some app cleanup.

Kind: Exported function

signoutUser() ⏏

Handles the workflow for signing out the current user. The user will be presented with a dialog box asking them to confirm signout, and optionally to sign out of the current identity provider as well as the app. Fires the user-signout event when complete.

Kind: Exported function

onUserLogin(user) ⇒ Promise.<object>

This function is called after a user login has completed, which can happen after a new login workflow, or after a re-login from a previous session. Fires the user-login event when complete.

Kind: Exported function
Returns: Promise.<object> - Resolves after the CloudStore updates are completed

Param Type Description
user object The user object that was returned from the login workflow

registerAPI(method, urlInvocation, apiRouteFunction) ⏏

Registers a function that will respond to an API request from the Browser. This will set up a route with the express middleware in the Main node.js process. For Browser pages, the /scripts/webutils.js file contains an api() function that can be used to invoke a route registered with registerAPI().

Kind: Exported function
See: Routing in Express

Param Type Description
method string the HTTPS method such as 'GET', 'POST', etc.
urlInvocation string the localhost URL to invoke, e.g. "/api/loginready"
apiRouteFunction function API request called in express style i.e. (req,res,next)

startMainApp(options) ⏏

This is it, the function that kicks it all off.

Kind: Exported function

Param Type Description
options object May contain show, width, height, title, main_html