/* Copyright (c) 2004-2006, The Dojo Foundation All Rights Reserved. Licensed under the Academic Free License version 2.1 or above OR the modified BSD license. For more information on Dojo licensing, see: http://dojotoolkit.org/community/licensing.shtml */ dojo.require("dojo.event"); dojo.provide("dojo.event.topic"); dojo.event.topic = new function(){ this.topics = {}; this.getTopic = function(topicName){ if(!this.topics[topicName]){ this.topics[topicName] = new this.TopicImpl(topicName); } return this.topics[topicName]; } this.registerPublisher = function(topic, obj, funcName){ var topic = this.getTopic(topic); topic.registerPublisher(obj, funcName); } this.subscribe = function(topic, obj, funcName){ var topic = this.getTopic(topic); topic.subscribe(obj, funcName); } this.unsubscribe = function(topic, obj, funcName){ var topic = this.getTopic(topic); topic.unsubscribe(obj, funcName); } this.destroy = function(topic){ this.getTopic(topic).destroy(); delete this.topics[topic]; } this.publishApply = function(topic, args){ var topic = this.getTopic(topic); topic.sendMessage.apply(topic, args); } this.publish = function(topic, message){ var topic = this.getTopic(topic); // if message is an array, we treat it as a set of arguments, // otherwise, we just pass on the arguments passed in as-is var args = []; // could we use concat instead here? for(var x=1; x