]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/topic.js.uncompressed.js
1 define("dojo/topic", ["./Evented"], function(Evented
){
3 // The export of this module is a pubsub hub
4 // You can also use listen function itself as a pub/sub hub:
5 // | topic.subscribe("some/topic", function(event){
6 // | ... do something with event
8 // | topic.publish("some/topic", {name:"some event", ...});
10 var hub
= new Evented
;
12 publish: function(topic
, event
){
14 // Publishes a message to a topic on the pub/sub hub. All arguments after
15 // the first will be passed to the subscribers, so any number of arguments
16 // can be provided (not just event).
18 // The name of the topic to publish to
20 // An event to distribute to the topic listeners
21 return hub
.emit
.apply(hub
, arguments
);
23 subscribe: function(topic
, listener
){
25 // Subcribes to a topic on the pub/sub hub
27 // The topic to subscribe to
29 // A function to call when a message is published to the given topic
30 return hub
.on
.apply(hub
, arguments
);