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
Configs
9Optional function that will be passed an instance prior to destroying it.
| Parameter | Type | Description |
|---|---|---|
name | String | The property name in the Dynamic object by which the new instance may be referenced |
instance | Object | The value of the property |
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.
Optional function to call as instances are created. Each new instance is passed to this function.
| Parameter | Type | Description |
|---|---|---|
instance | Object | The newly created instance. |
key | String | The property name in the dynamic object by which the new instance may be referenced. |
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.
The owning object to pass along to the instances as the ownerName property.
The property name by which to store the owner on each instance.
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.
| Parameter | Type | Description |
|---|---|---|
config | Object | The config object used to create the object |
name | String | The property name in the Dynamic object by which the new instance may be referenced |
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.
| Parameter | Type | Description |
|---|---|---|
config | * | The original value of the config object parameter |