AddonSettings

Caching wrapper for AddonSettings API that does save and load settings.

Source:

Requires

Methods

(static) clearCache() → {void}

Source:
Deprecated:

Clears the stored/cached values.

Usually you should not call this, but just reload the data with loadOptions in case you need this. Otherwise, this leaves the module in an uninitalized/unexpected state.

Returns:
Type
void

(static) get(optionopt) → {Promise}

Source:

Returns the add-on setting to use in add-on.

If only a single option is requested (option=string) the result of the promise will be that return value. Otherwise, you can pass no parmeter or "null" and it will return all saved config values.

Parameters:
Name Type Attributes Default Description
option string | null <optional>
null

name of the option

Throws:

if option is not available or other (internal) error happened

Type
Error
Returns:

resulting in single value or object of values or undefined

Type
Promise

(static) getDefaultValue(option) → {Object|undefined}

Source:

Get the default value for a seting.

Returns undefined, if option cannot be found.

Parameters:
Name Type Description
option string | null

name of the option

Throws:

if option is not available

Type
Error
Returns:
Type
Object | undefined

(static) loadOptions() → {Promise}

Source:

Fetches all options, so they can be used later.

This is basically the init method! It returns a promise, but that does not have to be used, because the module is built in a way, so that the actual getting of the options is waiting for the promise.

Returns:
Type
Promise

(static) set(option, valueopt) → {Promise}

Source:
See:

Sets the settings.

Note you can also pass a key -> value object to set here, as with the usual "set" storage API, or use the simplified two-parmeters version.

Parameters:
Name Type Attributes Description
option Object | string

keys/values to set or single value

value Object <optional>

if only a single value is to be set

Throws:
TypeError
Returns:
Type
Promise

(static) setCaching(enableCachingNew) → {void}

Source:

Caching is enabled by default. Call this with "false" to disable.

Parameters:
Name Type Description
enableCachingNew boolean
Returns:
Type
void