加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
topic.js 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
define(["./Evented"], function(Evented){
// module:
// dojo/topic
var hub = new Evented;
return {
// summary:
// Pubsub hub.
// example:
// | topic.subscribe("some/topic", function(event){
// | ... do something with event
// | });
// | topic.publish("some/topic", {name:"some event", ...});
publish: function(topic, event){
// summary:
// Publishes a message to a topic on the pub/sub hub. All arguments after
// the first will be passed to the subscribers, so any number of arguments
// can be provided (not just event).
// topic: String
// The name of the topic to publish to
// event: Object
// An event to distribute to the topic listeners
return hub.emit.apply(hub, arguments);
},
subscribe: function(topic, listener){
// summary:
// Subscribes to a topic on the pub/sub hub
// topic: String
// The topic to subscribe to
// listener: Function
// A function to call when a message is published to the given topic
return hub.on.apply(hub, arguments);
}
};
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化