Events

The Viz class acts as the central event hub. This way you only have to go to one place for all events. It also means that events can be raised on an object that may not have been created yet. For example, the marksselection event can be raised for a particular sheet even though the Sheet object hasn't been created yet. Each event contains an anonymous object with information pertaining to that event, such as the sheet the event occurred on.

Listening to an event is done by calling Viz.addEventListener(type, callback) and passing in a function callback. Here's an example of listening to an event:

viz.addEventListener("marksSelection", function (marks) {
   changeMySelectionUI(marks);
});

Removing a listener is done by calling Viz.removeEventListener(type, listener) and passing in the same callback function that was passed into Viz.addEventListener(). For example:

function changeMySelectionUI(marks) {
   viz.removeEventListener("marksSelection", changeMySelectionUI);
}
viz.addEventListener("marksSelection", changeMySelectionUI);

Events are multicast delegates, meaning that multiple listeners are supported. The order in which notifications are called is not specified. Every event callback takes a single object containing a pointer to the Viz that raised the event. Each event also adds additional fields to the event, as specified in the API Reference.


Thanks for your feedback!Your feedback has been successfully submitted. Thank you!