Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.52 (release candidate)
collection
interactivityModel
Interfaces

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 | Methods

Constructor

Monitor(dataManager)

Parameters:

ParameterDefault valueDescription
dataManager *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IDataManager|IOptionManager

Data manager.

* Mandatory parameter/option.

Example:

// Tracking changes to placemark options
var placemark = new ymaps.Placemark([0, 0]),
    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

NameReturnsDescription
add(name, changeCallback[, context[, params]])

Monitor

Enables monitoring particular fields or a group of data fields.

forceChange()

Monitor

Initializes checking for changes to values of the monitored data fields.

get(name)

Object

Returns the current value of one of the monitored data fields.

remove(name)

Monitor

Disables monitoring particular fields or a group of data fields.

removeAll()

Monitor

Disables monitoring for all data fields.

Methods details

add

Enables monitoring particular fields or a group of data fields.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
name*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String[][]|String[]

Name or array of names of data fields that monitoring is being set up for.

changeCallback*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Function

Handler for changes to data fields, or one of the data fields from a group.

context

Type: Object

Context for the handler of data changes and for options handlers.

params

Type: Object

Optional parameters.

params.compareCallback

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.

params.compareCallbacks

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.

params.defaultValue

Type: Object

The default value that is used if the data field is not defined.

params.defaultValues

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.

params.resolveCallback

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.

params.resolveCallbacks

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:

ParameterDefault valueDescription
name*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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:

ParameterDefault valueDescription
name*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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.