@helios-interactive/garuda-js

1.1.0 • Public • Published

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

Param Type Description
[prop] string OR Object string - namespacecd property, OR options object
[options] Object options object

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

Set a property or properties

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

Param Type Description
propOrVal string OR Object string: 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);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @helios-interactive/garuda-js

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

18.9 kB

Total Files

15

Last publish

Collaborators

  • caitlinboldt
  • adammcfadden
  • chickenfoot
  • mneil
  • halfwizard