Monitor
Object that tracks changes to certain data fields in the specified data manager. It can also be used for tracking changes to options.
Constructor
Monitor(dataManager)
Parameters:
Parameter |
Default value |
Description |
— |
Type: IDataManager|IOptionManager Data manager. |
* Mandatory parameter/option.
Example:
// Tracks changes to placemark options.
var placemark = new ymaps.Placemark([0, 0]);
var optionMonitor = new ymaps.Monitor(placemark.options);
optionMonitor.add("cursor", function (newValue) {
alert("cursor: " + newValue);
});
myMap.geoObjects.add(placemark);
// Outputs the string "cursor: arrow".
myMap.options.set({
geoObjectCursor: "arrow"
});
Methods
Name |
Returns |
Description |
add(name, changeCallback[, context[, params]]) |
Enables monitoring particular fields or a group of data fields. |
|
Initializes checking for changes to values of the monitored data fields. |
||
Object |
Returns the current value of one of the monitored data fields. |
|
Disables monitoring particular fields or a group of data fields. |
||
Disables monitoring for all data fields. |
Methods details
add
{Monitor} add(name, changeCallback[, context[, params]])
Enables monitoring particular fields or a group of data fields.
Returns self-reference.
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: String|String[] Name or array of names of data fields that monitoring is being set up for. |
— |
Type: Function Handler for changes to data fields, or one of the data fields from a group. |
|
— |
Type: Object Context for the handler of data changes and for options handlers. |
|
— |
Type: Object Optional parameters. |
|
— |
Type: Function Handler that compares the old and new values of data fields. Takes two arguments: the old value and the new value. Lower priority relative to handlers set using the compareCallbacks parameter. |
|
— |
Type: Object Hash in the format {data field name: reference to handler}. This parameter is for setting individual handlers for comparing values for various data fields in a group. |
|
— |
Type: Object The default value that is used if the data field is not defined. |
|
— |
Type: Object Hash in the format {data field name: default value}. This parameter is for setting individual default values for various data fields in a group. |
|
— |
Type: Function Handler that allows the data field value. Takes two arguments; the data field name and the reference to the data manager. Lower priority relative to handlers set using the resolveCallbacks parameter. |
|
— |
Type: Object Hash in the format {data field name: reference to handler}. This parameter is for setting individual handlers for allowing values for various data fields in a group. |
* Mandatory parameter/option.
forceChange
{Monitor} forceChange()
Initializes checking for changes to values of the monitored data fields.
Returns self-reference.
get
{Object} get(name)
Returns the current value of one of the monitored data fields.
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: String Data field name. |
* Mandatory parameter/option.
remove
{Monitor} remove(name)
Disables monitoring particular fields or a group of data fields.
Returns self-reference.
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: String|String[] Name or array of names of data fields that monitoring is being disabled for. |
* Mandatory parameter/option.
removeAll
{Monitor} removeAll()
Disables monitoring for all data fields.
Returns self-reference.
Mandatory parameter/option.