Several classes in the API have been enhanced to support
.on() style events, also referred to as evented. Specifically, esri/map as well as all classes in esri/layers and all esri/tasks now support class.on() style events. Classes in esri/dijit will have support for this style of event managament at a future release.
Prior to this release, to listen to an event, the recommendation was to use
dojo/_base/connect. We recommend using the
.on() method where available. Below is a comparison:
Note that when using
.on() event names have changed. Please consult the documentation for each class to find the correct name for an event. The pattern for the new names is that events are no longer prefixed with "on" and instead of being camel-cased, words in event names are all lower-case and separated by dashes.
In addition to event names changing, event handler arguments have changed as well. Again, please consult the documentation for each class when using new .on() style events to confirm how to access results from various events. The pattern for event arguments is that event handlers receive a single argument, which is an object. Use propeties of the event object to access the result of an event. For instance, when listening to a map's extent-change event, as in the example above, access the map's new extent with event.extent.
Some samples have been updated to demonstrate the new
.on() style event listening (as well as re-written to use AMD):
Additional samples that have been re-written to use AMD: