@helios-interactive/garuda-js
v1.1.0
Published
Garuda Config Management
Downloads
5
Keywords
Readme
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);
});