source: Dev/trunk/src/client/dojo/topic.js @ 513

Last change on this file since 513 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.0 KB
Line 
1define(["./Evented"], function(Evented){
2
3        // module:
4        //              dojo/topic
5
6        var hub = new Evented;
7        return {
8                // summary:
9                //              Pubsub hub.
10                // example:
11                //              |       topic.subscribe("some/topic", function(event){
12                //              |       ... do something with event
13                //              |       });
14                //              |       topic.publish("some/topic", {name:"some event", ...});
15
16                publish: function(topic, event){
17                        // summary:
18                        //              Publishes a message to a topic on the pub/sub hub. All arguments after
19                        //              the first will be passed to the subscribers, so any number of arguments
20                        //              can be provided (not just event).
21                        // topic: String
22                        //              The name of the topic to publish to
23                        // event: Object
24                        //              An event to distribute to the topic listeners
25                        return hub.emit.apply(hub, arguments);
26                },
27
28                subscribe: function(topic, listener){
29                        // summary:
30                        //              Subscribes to a topic on the pub/sub hub
31                        // topic: String
32                        //              The topic to subscribe to
33                        // listener: Function
34                        //              A function to call when a message is published to the given topic
35                        return hub.on.apply(hub, arguments);
36                }
37        };
38});
Note: See TracBrowser for help on using the repository browser.