Class Index | File Index

## Classes

- _global_
- comb
- comb.array
- comb.characters
- comb.collections
- comb.collections.AnderssonTree
- comb.collections.AVLTree
- comb.collections.BinaryTree
- comb.collections.Collection
- comb.collections.HashTable
- comb.collections.Heap
- comb.collections.Iterable
- comb.collections.MaxHeap
- comb.collections.MinHeap
- comb.collections.Pool
- comb.collections.PriorityQueue
- comb.collections.Queue
- comb.collections.RedBlackTree
- comb.collections.Stack
- comb.collections.Tree
- comb.date
- comb.logging
- comb.logging.appenders
- comb.logging.appenders.Appender
- comb.logging.appenders.ConsoleAppender
- comb.logging.appenders.FileAppender
- comb.logging.appenders.JSONAppender
- comb.logging.appenders.RollingFileAppender
- comb.logging.BasicConfigurator
- comb.logging.Level
- comb.logging.Logger
- comb.logging.PropertyConfigurator
- comb.number
- comb.plugins
- comb.plugins.Broadcaster
- comb.plugins.Middleware
- comb.Promise
- comb.PromiseList
- comb.regexp
- comb.string

# Class comb.plugins.Broadcaster

Defined in: Broadcaster.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| comb.plugins.Broadcaster() Plugin to allow a class to easily broadcast events

Method Summary
Method Attributes | Method Name and Description
--- | ---
| broadcast(name, args) Broadcasts an event from an object
| listen(topic, callback) Listens to a broadcasted event Simimlar to comb.listen
| unListen(handle) Disconnects a listener Similar to comb.unListen

Class Detail
comb.plugins.Broadcaster()
Plugin to allow a class to easily broadcast events

    var Mammal = define(comb.plugins.Broadcaster, {
      instance : {

         constructor: function(options) {
             options = options || {};
             this.super(arguments);
             this._type = options.type || "mammal";
         },

         speak : function() {
             var str = "A mammal of type " + this._type + " sounds like";
             this.broadcast("speak", str);
             this.onSpeak(str);
             return str;
         },

         onSpeak : function(){}
       }
    });

    var m = new Mammal({color : "gold"});
    m.listen("speak", function(str){
         //called back from the broadcast event
          console.log(str);
    });
    m.speak();

Method Detail
broadcast(name, args)
Broadcasts an event from an object

Parameters:
name
  the name of the event to broadcast
{Object|String|Function|Date|Number} args Optional
  variable number of arguments to pass to listeners, can be anything

{Array} listen(topic, callback)
Listens to a broadcasted event Simimlar to comb.listen

Parameters:
{String} topic
  the topic to listen to
{Function} callback
  the function to callback on event publish

Returns:
  {Array} handle to disconnect a topic

unListen(handle)
Disconnects a listener Similar to comb.unListen

Parameters:
handle
  disconnect a handle returned from Broadcaster.listen

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Oct 25 2011 13:20:07 GMT-0500 (CDT)