Construct a new attached property.
The options for initializing the property.
The human readable name for the property.
Coerce the value for the given owner.
Compare the old value and new value for equality.
Get or create the default value for the given owner.
Run the change notification if the given values are different.
Explicitly coerce the current property value for a given owner.
The property owner of interest.
If the value has not yet been set, the default value will be computed and used as the previous value for the comparison.
Get the current value of the property for a given owner.
The property owner of interest.
The current value of the property.
If the value has not yet been set, the default value will be computed and assigned as the current value of the property.
Set the current value of the property for a given owner.
The property owner of interest.
The value for the property.
If the value has not yet been set, the default value will be computed and used as the previous value for the comparison.
Clear the stored property data for the given owner.
The property owner of interest.
This will clear all property values for the owner, but it will not run the change notification for any of the properties.
Generated using TypeDoc
A class which attaches a value to an external object. The namespace for the
AttachedProperty
class statics.Notes
Attached properties are used to extend the state of an object with semantic data from an unrelated class. They also encapsulate value creation, coercion, and notification.
Because attached property values are stored in a hash table, which in turn is stored in a WeakMap keyed on the owner object, there is non-trivial storage overhead involved in their use. The pattern is therefore best used for the storage of rare data.