Config

This class holds the description of a config property. Only one instance of this class is needed for each config name (e.g., "text"). If config options are supplied, however, they also contribute to the cached instance.

Instances should always be retrieved by calling Config.get().

The Configs of this class correspond to options that can be supplied to the get() method. These affect the behavior of the config property in some way, as descried by their respective documentation.

This class is not used directly.

The Setter

The primary functionality provided by Config is its standard setter. This setter function ensures consistent behavior when modifying config properties.

The standard setter algorithm is as follows (using the 'text' config for illustration):

  • If the class defines a changeText() method, call it passing the new value and the current value: changeText(newText, oldText).
    Then:
    • If changeText() exits without returning a value (i.e., undefined), exit and do nothing further. The assumption is that the changer method has done all that is required.
    • Otherwise, the return value of changeText() replaces the incoming value passed to the setter.
  • If the new value (or the value returned by changeText()) is !== to the current value:
    • Update the stored config value in this._text.
    • If the class defines an updateText() method, call it passing the new value and the previous value. updateText(newText, oldText)
    • Any return value from updateText() is stored in this.textUpdated.
    • If the class defines an onConfigChange() method, call it passing an object with the following properties:
      • name - The config's name
      • value - The new value
      • was - The previous value
      • config - The Config instance.

NOTE: unlike changeText() and updateText(), the name of the onConfigChange() method is unaffected by the config's name.

Configs

1
date: Boolean= false

Indicates that values are Date objects.