Show:

A utility for setting options in a class that enables patching options with prescribed defaults and emitting change events when options are changed. Recursively defined for nested options objects.

Note: only JSONable objects are allowed, so no functions.

Constructor

Core.OptionsManager

(
  • value
)
private

Parameters:

  • value Object

    Options object literal

Methods

"on"

(
  • type
  • handler
)

Adds a handler to the type channel which will be executed on emit.

Parameters:

get

(
  • key
)
Object

Look up options value by key or get the full options hash.

Parameters:

Returns:

Object:

Associated object or full options hash

getOptions

()

Alias for get

key

(
  • key
)
OptionsManager

Return OptionsManager based on sub-object retrieved by key.

Parameters:

Returns:

OptionsManager:

Value

off

(
  • type
  • handler
)

Removes the handler from the type channel. This undoes the work of on.

Parameters:

OptionsManager.patch

(
  • options
  • patch
)
Object

Constructor method. Create OptionsManager from source dictionary with arguments overriden by patch dictionary.

Parameters:

  • options Object

    Options to be patched

  • patch ...Object

    Options to overwrite

Returns:

Object:

source

OptionsManager.patch

(
  • options
  • overrides
)
Object

Constructor method. Convenience method to set options with defaults on an object instance.

Parameters:

  • options Object

    Options to be patched

  • overrides ...Object

    Options to overwrite

Returns:

Object:

source

patch

(
  • options
)
OptionsManager

Patch options with provided patches. Triggers change event on the object.

Parameters:

  • options Object

    Patch options

Returns:

OptionsManager:

this

set

(
  • key
  • value
)
OptionsManager

Set key to value. Outputs change event if a value is overwritten.

Parameters:

Returns:

OptionsManager:

Updated OptionsManager

setOptions

()

Alias for patch