1.1.0 • Published 6 years ago

@helios-interactive/garuda-js v1.1.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
6 years ago

Garuda

Config Manager

Garuda loads configuration for apps from the file /garuda.config.json.

Additionally, if a the file /garuda.local.config.json is found, settings in that file will be merged into the configuration loaded from /garuda.config.json.

Functions and Methods

garuda()

Alias of garuda.set()

garuda.get(prop, options) ⇒ Promise.<Object>

Get a property from garuda. All keys are found by string. garuda.get('path.to.property.at.index.2')

Returns: Promise.<Object> - - A promise containing the config

ParamTypeDescription
propstring OR Objectstring - namespacecd property, OR options object
optionsObjectoptions object

garuda.set(propOrVal, value) ⇒ Promise.<Object>

Set a property or properties

Returns: Promise.<Object> - - A promise containing the updated config object

ParamTypeDescription
propOrValstring OR Objectstring: namespaced property OR val: config object
value\*when first parameter is a string, sets specified property to this string

garuda.retrieveLocalStorage() ⇒ Object

Retrieves config from local storage

Returns: Object - - config as stored in local storage

garuda.clearLocalStorage()

Clears garuda local storage and resets config to configs loaded from server. Note: When config is changed through garuda.set() it automatically saved to local storage. Clearing local storage reverts garuda to configs loaded from the server.

Events

garuda-updated

Every time the config is updated using garuda.set() or it's alias, Garuda dispatches an the event garuda-updated on the document. The event parameter sent to the callback function of the event listener contains a details property that includes an object detailing the updates.

document.addEventListener('garuda-updated', (e) => {
  const updates = e.detail;
  console.log(updates);
});
1.1.0

6 years ago

1.0.0

6 years ago