The Dojo Toolkit has a single event bus that it uses to send messages between application objects. The Dojo methods dojo.subscribe() and dojo.publish() implement this bus. This is different than the event model of General Interface in which application events are usually published by any number of event dispatchers to any number of subscribers. The object jsx3.util.Dojo.hub provides an adapter to the Dojo event hub within General Interface. This object implements jsx3.util.EventDispatcher so it can be used like any other event dispatcher in a General Interface application. Use this object to publish events for broadcast on the Dojo hub and to subscribe to events published on the Dojo hub. The following example shows how to publish an event to the Dojo event hub. jsx3.util.Dojo.hub.publish({subject:"eventId", greeting:"hello"});
The following example shows how to subscribe to events from the Dojo hub. jsx3.util.Dojo.hub.subscribe("eventId", null, function(message) {
...
});
Ordered parameters from the Dojo API are available for the message object. In the previous example, you would use message[0] to access the first parameter that is passed to the publish method. |
Contents
|
