src/aria/core/JsObject.js
function (callbacksMap, name, scope, fn, src, firstOnly) {
        if (callbacksMap == null) {
            return; // nothing to remove
        }

        var arr = callbacksMap[name];

        if (arr) {
            var length = arr.length, removeThis = false, cb;
            for (var i = 0; i < length; i++) {
                cb = arr[i];

                // determine if callback should be removed, start with
                // removeThis = true and then set to false if
                // conditions are not met

                // check the interface from which we remove the listener
                removeThis = (!src || cb.src == src)
                        // scope does not match
                        && (!scope || scope == cb.scope)
                        // fn does not match
                        && (!fn || fn == cb.fn);

                if (removeThis) {
                    // mark the callback as being removed, so that it can either
                    // still be called (in case of CallEnd in
                    // interceptors, if CallBegin has been called) or not called
                    // at all (in other cases)
                    cb.removed = true;
                    arr.splice(i, 1);
                    if (firstOnly) {
                        break;
                    } else {
                        i--;
                        length--;
                    }
                }
            }
            if (arr.length === 0) {
                // no listener anymore for this event/interface
                callbacksMap[name] = null;
                delete callbacksMap[name];
            }
        }
    }
function (callbacksMap, name, scope, fn, src, firstOnly) {
        if (callbacksMap == null) {
            return; // nothing to remove
        }

        var arr = callbacksMap[name];

        if (arr) {
            var length = arr.length, removeThis = false, cb;
            for (var i = 0; i < length; i++) {
                cb = arr[i];

                // determine if callback should be removed, start with
                // removeThis = true and then set to false if
                // conditions are not met

                // check the interface from which we remove the listener
                removeThis = (!src || cb.src == src)
                        // scope does not match
                        && (!scope || scope == cb.scope)
                        // fn does not match
                        && (!fn || fn == cb.fn);

                if (removeThis) {
                    // mark the callback as being removed, so that it can either
                    // still be called (in case of CallEnd in
                    // interceptors, if CallBegin has been called) or not called
                    // at all (in other cases)
                    cb.removed = true;
                    arr.splice(i, 1);
                    if (firstOnly) {
                        break;
                    } else {
                        i--;
                        length--;
                    }
                }
            }
            if (arr.length === 0) {
                // no listener anymore for this event/interface
                callbacksMap[name] = null;
                delete callbacksMap[name];
            }
        }
    }
function ( callbacksMap , name , scope , fn , src , firstOnly ) { if ( callbacksMap == null ) { return ; // nothing to remove } var arr = callbacksMap [ name ] ; if ( arr ) { var length = arr . length , removeThis = false , cb ; for ( var i = 0 ; i < length ; i ++ ) { cb = arr [ i ] ; // determine if callback should be removed, start with // removeThis = true and then set to false if // conditions are not met // check the interface from which we remove the listener removeThis = ( ! src || cb . src == src ) // scope does not match && ( ! scope || scope == cb . scope ) // fn does not match && ( ! fn || fn == cb . fn ) ; if ( removeThis ) { // mark the callback as being removed, so that it can either // still be called (in case of CallEnd in // interceptors, if CallBegin has been called) or not called // at all (in other cases) cb . removed = true ; arr . splice ( i , 1 ) ; if ( firstOnly ) { break ; } else { i -- ; length -- ; } } } if ( arr . length === 0 ) { // no listener anymore for this event/interface callbacksMap [ name ] = null ; delete callbacksMap [ name ] ; } } }
Private method used to remove callbacks from a map of callbacks associated to a given scope and function
@param {Object} callbacksMap map of callbacks, which can be currently: obj._listeners
@param {String} name [mandatory] name in the map, may be the event name (if callbacksMap == _listeners)
@param {Object} scope [optional] if specified, only callbacks with that scope will be removed
@param {Function} fn [optional] if specified, only callbacks with that function will be removed
@param {Object} src [optional] if the method is called from an interface wrapper, must be the reference of the
interface wrapper. It is used to restrict the callbacks which can be removed from the map.
@param {Boolean} firstOnly. if true, remove only first occurence.
@private
Private method used to remove callbacks from a map of callbacks associated to a given scope and function