x6events.subscribeToEvent
The Javascript method x6events.subscribeToEvent allows an
object to subscribe to a named event. That object will
then be notified whenever the event fires. See the
method x6events.notify for more information on how
the notification is handled.
No return value
x6events.fireEvent
subscribeToEvent: function(eventName,id) {
if(id=='undefined') {
x6.console.error('x6events.subscribeToEvent. Second parameter '
+' undefined. First parameter: '+eventName
);
}
else if(id==null) {
x6.console.error('x6events.subscribeToEvent. Second parameter '
+' null. First parameter: '+eventName
);
}
else {
// First determine if we have any listeners for this
// event at all. If not, make up the empty object
if( typeof(this.subscribers[eventName])=='undefined') {
this.subscribers[eventName] = [ ];
}
if(this.subscribers[eventName].indexOf(id)==-1) {
this.subscribers[eventName].push(id);
}
if( typeof(this.subsById[id])=='undefined') {
this.subsById[id] = [ ];
}
if(this.subsById[id].indexOf(eventName)==-1) {
this.subsById[id].push(eventName);
}
}
},