Adds a listener for data changes. If the listener was already added, nothing happens.
Callback to add
a function that can be called to remove the listener. It just calls removeChangeListener with aCallback.
Adds a listener for changes to a certain property. If the listener was already added for the property, nothing happens.
Name of property
Callback function to call when property changes value
a function that can be called to remove the listener. It just calls removePropertyChangeListener with aProperty and aListener.
Protected
addAdds a validator for a certain property.
Property name
A validator for a value or property
Protected
changedThis method can be called when a property changes value. If the instance is locked via lock the names are stored. Else the onPropertiesChanged method is called with the list of names.
The function accepts a variable number of name parameters
Rest
...aNames: string[]One or more property names that changed
Checks if a value is valid for a property.
If the property is unknown or does not have any validator attached to it, the method returns true.
Property name
Value to test
True if the value is valid for property, otherwise false.
Protected
onThis method is called whenever changed is called or the data structure is unlocked and there are changed properties.
The default implementation invokes all the registered listeners. Subclasses can override this method to take additional actions.
List of property names
Protected
processProtected
Processes a possible property assignment. If aNewValue is not undefined, compare it to the current value and when not equal call changed for the property.
When anEqualFunction is not defined, the method uses ===.
The aTransformFunction can be used for example to keep a value within a certain range.
Property name
Current value of the property
New value of the property or undefined if no new value needs to be set
Function that is called to set the new changed value (if any)
Optional
aTransformFunction: ((value) => T)Function to transform aNewValue with before comparing and assigning it
Optional
anEqualFunction: ((value0, value1) => boolean)Custom compare function that should return true if objects are equal. When null, the method uses === to compare the values.
the current or new property value
Removes a listener for data changes.
Callback to remove
Removes a listener for changes to a certain property.
Name of property
Listener to remove
Sets a property to a value. The method checks if the property is a function. If it is, the method will call the function passing the value as parameter. Else the method will assign the value directly and call changed.
Property name
Value to assign
Unlocks the model instance. If a call matches the first call to lock, call onPropertiesChanged if there are any pending changes.
current lock count
UFModel implements IUFModel and adds support change events and dirty state.