Aggregated Properties
Discusses the purpose and use of aggregated properties
Background
As you have learned in Classes and Instances, it is possible to both define a class, and then extend the class to create a new class. This is our implementation of inheritance from object-oriented programming. When you extend an existing class, however, the extended class overwrites the values of the base class. This happens for both data properties and methods.
When a method overwrites the method from its base class, you can use the _super
method to pass execution to the base class. But, when a data property overwrites its corresponding data property on the base class, the data property on the base class is not easily accessible. What about when you do not want to overwrite the data property on the base class, but extend it—similar to how we extend class?
By default, data properties from an extended class hide the data properties on its base class, making them hard to access.
This is where aggregated properties come into the picture. The purpose of an aggregated property is to combine the property of the base class with that of the extended class. This allows the data properties to be extended in a similar manner to how a class definition is extended.
Supported Types
Our object model supports the following types of aggregated properties:
Concatenated Properties
Concatenated properties apply to array data properties. You use the concatProperties
property on the class definition to define the list of properties that should be concatenated instead of overwritten.
The concatenated properties also apply when initializing a created object.
Merged Properties
Merged properties apply to plain JavaScript object data properties. You use the mergedProperties
property on the class definition to define the list of properties that should be merged instead of overwritten.
The merged properties also apply when initializing a created object.
Last updated