DynamicObject
internal
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
Configs are options you supply in a configuration object when creating an instance of this class-
Optional name of the config property managed by this instance. If changes are made directly, this property is used to run the
onConfigChangemethod of theowner. -
The factory to use to create instances.
-
By default, the name of the member is used for the type. Set this config to
trueto also allow the config object for a property to contain atypeproperty. Set this tofalseto 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
ownerNameproperty. -
The property name by which to store the
owneron each instance. -
Set to
falseto prevent using aProxyeven if that JavaScript platform feature is available. Using aProxyis ideal because it allows for all forms of access to the dynamic properties to be handled instead of only those that have predefined configuration values.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Holds config objects for each defined object. These are used to hold class and instance config values and use them to create instances on first request, or when
flush()is called. Further, if the instance is initially assigned instead of retrieved, these values act as the defaults for the instance and are combined with those provided in the assignment. -
This object holds the actual instances that are retrieved by the dynamic accessor or
Proxy. -
The object that contains the dynamic accessors for each instance. This object is not used when using a
Proxy. -
Returns the
Proxyinstance used to manage dynamic assignments. If the JavaScript platform does not support theProxyclass, this will benull. -
Returns the object that contains the dynamic properties. This may be a
Proxyinstance or an object with getter and setter accessors.
Functions
Functions are methods available for calling on the class-
flush( )internal
Ensures that all defined members are touched to trigger their creation.