Class TKObject
The TKObject class is the base class for all TuneKit objects and provides a way to receive and trigger notifications when a JavaScript property changes.
Observing a property on an object is done through the
addPropertyObserver
method, specifying the property to observe as well as the object that will
receive the notifications of the property change. Likewise, an object can stop observing such changes using
the removePropertyObserver
method. When a property value changes, the author needs to call the
notifyPropertyChange
method so that registered observers will be notified. Note that synthetized
properties will automatically trigger notifications when changed, so in this case, setters need not
manually call notifyPropertyChange
.
Finally, TKObject also provides the callSuper
method to call the superclass's implementation
of an overload method.
Defined in: Object.js.
Constructor Attributes | Constructor Name and Description |
---|---|
TKObject ()
|
Method Attributes | Method Name and Description |
---|---|
addPropertyObserver (propertyName, observer, methodName)
Adds an observer for the named property on this object.
|
|
callMethodNameAfterDelay (methodName, delay)
Calls a method on this object after a delay, allowing any number of optional extra arguments to be
passed after the first two mandatory ones.
|
|
This method calls the object's superclass implementation of the current method
|
|
notifyPropertyChange (propertyName)
Triggers a notification that the given property on this object has changed.
|
|
removePropertyObserver (propertyName, observer)
Removes the observer for the named property on this object.
|
- Parameters:
- {String} propertyName
- The property to observe.
- {Object} observer
- The object that will be notified when the property is changed.
- {String} methodName
- The optional method name that will be called on the observer when the property is changed.
If this property is not provided, the
observer
must implement theTKPropertyValueChange
protocol.
- Parameters:
- {String} methodName
- The method name to be called.
- {int} delay
- The delay in miliseconds.
- Returns:
- {int} The timeout that can be used to call
clearTimeout
.
notifyPropertyChange
has to be called manually so that observers are notified.
- Parameters:
- {String} propertyName
- The observed property.
- Parameters:
- {String} propertyName
- The observed property.
- {Object} observer
- The object that was notified when the property changed.
- Returns:
- {bool} Whether an observer was removed