GlobalContext

GlobalContext

GlobalContext is a single, globally available object that provides information and services to all components of the application.

Constructor

new GlobalContext()

Constructs a new GlobalContext. Don't call this yourself, as it's called when the module loads. You'll want to access pre-instantiated Context object that this module exports.

Source:

Members

childProcesses

This object contains info about child processes spawned by the current DART process. While the persistent DartProcess object stores info in a local DB about all child processes DART has spawned, this hash includes information about running child processes only.

This objects keys are UUIDs. Each key is the UUID of a DartProcess object. The values are live Node.js Process objects. If a DartProcess.id key is not in the hash of childProcesses, it is not currently running.

Source:

config :Config

config is the current configuration, either user or test, based on whether isTestEnv is true.

Source:

dataStores :Object.<string, JsonStore>

dataStores is a hash of the application data storage files. The key is the object name (type of object stored in the file), and the value is the queryable JsonStore object holding the data.

Source:

isDevEnv :boolean

isDevEnv indicates whether we're currently running in a development environment. For this to work, the package.json file needs the following entry in "scripts":

Source:
Example
"scripts": {
    ...
    "start": "NODE_ENV=dev electron .",
    ...
}

isTestEnv :boolean

isTestEnv indicates whether we're currently running as part of a test suite. It will be true when process.env.NODE_ENV === 'test', which Jest sets by default when you run npm test.

Source:

logger :Object

logger is an instance of the WinstonJS logger, the system-wide logging facility. See https://github.com/winstonjs/winston.

Source:

slowMotionDelay :number

Force the bagger and the validator to elay this many milliseconds between operations. This slows down the bagging and validation processes. We use this only for UI testing during development. In production, this should always be set to zero.

Source:

y18n :Object

y18n allows us to translate/localize the UI.

Source:

Methods

dartReleaseNumber() → {string}

Returns the release number of this DART build. For example, "2.0.16". If you need more complete information, use GlobalContext#dartVersion.

Source:

dartVersion() → {string}

Returns the full version of DART, including which Node version DART is using and the OS platform, architecture, and release number.

Source:

db(name)

Returns the JsonStore with the specified name (class name), creating it first if necessary.

Parameters:
Name Type Description
name string

The name of the datastore. This can be a class name, so each object type has it's own JSON data file.

Source:

electronIsRunning() → {number}

Returns true or false, indicating whether or not we're currently running in Electron. This will be false in jest tests and when DART runs as a command-line tool.

Source:

getPackageInfo() → {Object}

Returns a JavaScript object built from parsing this application's package.json file.

Source:

isElectronDevMode() → {boolean}

Returns true if we're running in Electron dev mode rather than in compiled mode.

Source: