lib/base/broadcast.js
function (obj, method, cb, scope) {
        var index,
            listeners;
        if (typeof method !== "string") {
            throw new Error("When calling connect the method must be string");
        }
        if (!func.isFunction(cb)) {
            throw new Error("When calling connect callback must be a string");
        }
        scope = obj || global;
        if (typeof scope[method] === "function") {
            listeners = scope[method].__listeners;
            if (!listeners) {
                var newMethod = wrapper();
                newMethod.func = obj[method];
                listeners = (newMethod.__listeners = []);
                scope[method] = newMethod;
            }
            index = listeners.push(cb);
        } else {
            throw new Error("unknow method " + method + " in object " + obj);
        }
        return [obj, method, index];
    }
function (obj, method, cb, scope) {
        var index,
            listeners;
        if (typeof method !== "string") {
            throw new Error("When calling connect the method must be string");
        }
        if (!func.isFunction(cb)) {
            throw new Error("When calling connect callback must be a string");
        }
        scope = obj || global;
        if (typeof scope[method] === "function") {
            listeners = scope[method].__listeners;
            if (!listeners) {
                var newMethod = wrapper();
                newMethod.func = obj[method];
                listeners = (newMethod.__listeners = []);
                scope[method] = newMethod;
            }
            index = listeners.push(cb);
        } else {
            throw new Error("unknow method " + method + " in object " + obj);
        }
        return [obj, method, index];
    }
function ( obj , method , cb , scope ) { var index , listeners ; if ( typeof method !== "string" ) { throw new Error ( "When calling connect the method must be string" ) ; } if ( ! func . isFunction ( cb ) ) { throw new Error ( "When calling connect callback must be a string" ) ; } scope = obj || global ; if ( typeof scope [ method ] === "function" ) { listeners = scope [ method ] . __listeners ; if ( ! listeners ) { var newMethod = wrapper ( ) ; newMethod . func = obj [ method ] ; listeners = ( newMethod . __listeners = [ ] ) ; scope [ method ] = newMethod ; } index = listeners . push ( cb ) ; } else { throw new Error ( "unknow method " + method + " in object " + obj ) ; } return [ obj , method , index ] ; }
Function to listen when other functions are called

@example

comb.connect(obj, "event", myfunc);
comb.connect(obj, "event", "log", console);

@param {Object} obj the object in which the method you are connecting to resides
@param {String} method the name of the method to connect to
@param {Function} cb the function to callback
@param {Object} [scope] the scope to call the specified cb in

@returns {Array} handle to pass to {@link comb.disconnect}
Function to listen when other functions are called