DynamicObject

This class is used to manage dynamic creation and configuration of individual properties of an object. This pattern is used to allow the names of an object to each represent a dynamically instantiated object. For example, the features config of Calendar is defined like so:

 class Calendar extends ... {
     static configurable = {
         features : {
             drag : {
                 // configs for Drag feature
             }
         }
     };
 }

This class is used to manage the features objects in the above case. The drag property value is promoted from the config object defined by the class and user instance on first request. Like config properties themselves, these features may access other features during their initialization. These accesses are trapped by this class to ensure the config object is promoted to an instantiated instance.

A factory is provided to this object to allow it to create instances from names like 'drag'.

Configs

9
cleanup: function

Optional function that will be passed an instance prior to destroying it.

ParameterTypeDescription
nameString

The property name in the Dynamic object by which the new instance may be referenced

instanceObject

The value of the property

Returns: void
configName: String

Optional name of the config property managed by this instance. If changes are made directly, this property is used to run the onConfigChange method of the owner.

created: function

Optional function to call as instances are created. Each new instance is passed to this function.

ParameterTypeDescription
instanceObject

The newly created instance.

keyString

The property name in the dynamic object by which the new instance may be referenced.

Returns: void
factory: Object

The factory to use to create instances.

inferType: Boolean | String= name

By default, the name of the member is used for the type. Set this config to true to also allow the config object for a property to contain a type property. Set this to false to ignore the name of the member and rely on the factory to process the config object.

owner: Object

The owning object to pass along to the instances as the ownerName property.

ownerName: String

The property name by which to store the owner on each instance.

setup: function

Optional function that will be passed a config object prior to instantiating an object. This function can either modify the passed object or return a new object.

ParameterTypeDescription
configObject

The config object used to create the object

nameString

The property name in the Dynamic object by which the new instance may be referenced

Returns: Object | null
transform: function

Optional function that will be passed a raw config object prior to processing and the value it returns replaces the raw value. This function is used to transform strings or arrays (for example) into proper config objects.

ParameterTypeDescription
config*

The original value of the config object parameter

Returns: *