- Legend to Symbols

-
Class nokia.maps.util.OObject
Class Summary
This class encapsulates an inheritable object that has observable properties.
new nokia.maps.util.OObject
([props])
Method Summary
addObserver
(key, callback, [context])
: nokia.maps.util.OObject
This method registers an observer for the property named by the caller.
get
(key)
: Variant
This method retrieves the value of the property with the name provided by the caller.
remove
(key)
: nokia.maps.util.OObject
This method removes the property with the name provided by the caller.
removeObserver
(key, callback, context)
: nokia.maps.util.OObject
This method removes the observer for the property named by the caller.
set
(nameOrObject, [value, [force]])
: nokia.maps.util.OObject
This method sets property values, using the property names and values supplied by the caller.
Constructor Detail
Method Detail
addObserver
(key, callback, [context])
: nokia.maps.util.OObject
This method registers an observer for the property named by the caller.
Note that modifying the property from within the observer is allowed, but
discouraged, because this forces the observer chain to be invoked again
and the old one aborted. This could lead to endless recursions and should
be done carefully.
Parameters:
| {String} | key | The name of the property to observe; the wild card "*" can be used to observe any property |
| {Function} | callback |
The function to be called if the observed property is modified; the
function must be able to receive the following arguments:
|
| {Object} | [context]: |
The context in which the given function should be called (default
null); if omitted, the global object is used
|
Returns:
| {nokia.maps.util.OObject} |
A reference to the given OObject instance
|
get
(key)
: Variant
This method retrieves the value of the property with the name provided
by the caller.
Parameters:
| {String} | key | The name of the property whose value is to be retrieved |
Returns:
| {Variant} |
The retrieved value of the property named by the caller or
undefined if no such property exists
|
remove
(key)
: nokia.maps.util.OObject
This method removes the property with the name provided by the caller.
Parameters:
| {String} | key | The name of the property to be removed |
Returns:
| {nokia.maps.util.OObject} |
The reference to the given OObject instance
|
removeObserver
(key, callback, context)
: nokia.maps.util.OObject
This method removes the observer for the property named by the caller.
Parameters:
| {String} | key | The name of the property that should no longer be observed |
| {Function} | callback | The observer method to be removed |
| {Object} | context | The context in which the given callback should be called |
Returns:
| {nokia.maps.util.OObject} |
The reference to the given instance of OObject
|
set
(nameOrObject, [value, [force]])
: nokia.maps.util.OObject
This method sets property values, using the property names and values
supplied by the caller.
The function takes an object whose keys match property names. The
values corresponding to the keys are the new values for the properties to
set.
To set a single property, the caller can provide two arguments, the name
of the property as a string and the value to be set.
For all properties, the following rules apply:
- If no property with the given name exists yet, the property is created.
- If a derived class defines a member method with the name of the key postfixed by "Setter", this method is called first; it is given the value and should return the "filtered" value to be set.
- After this "filtering" all registered observers of this value are called - if and only if this filtered value differs from the old value. The "observers" MUST NOT use code that leads to secondary setting of properties in this object/property or elsewhere, as this could result in endless loops.
set() are not tested
against hasOwnProperty().
Examples:
// Setting a single property:
obj.set("foo", 123);
// Setting multiple properties at once:
obj.set({ foo: 123, bar: "second one" });
// Definition of a "setter" within an object
// that has OObject in its prototype chain:
{
...
fooSetter: function (value) {
this.wantsToBeTriggered(); // if "foo" changes
// ensure the value stored to member "foo" is pure int
return value >>> 0;
},
...
}
Parameters:
| {String | Object} | nameOrObject | The name of the property to be set or the object from which to take the properties and their values |
| {Variant} | [value]: |
The value that should be applied to the property; if this argument is present,
nameOrObject is assumed to hold the name of a property
|
| {Boolean} | [force]: |
A flag to force an assignment, even if the old value is identical to
the new value (default false); the flag is taken into
account only on setting a single property via name, value
|
Returns:
| {nokia.maps.util.OObject} |
A reference to the given OObject instance
|