Add a function to the list of callbacks for an event
483979
function(event, fn) {
        // Get handle to event, creating it if necessary
        var callbacks = this._callbacks[event];
        if (!callbacks) {
            callbacks = this._callbacks[event] = (handlers[event] ||
                (handlers[event] = {}))[this[0]] = [];
            callbacks.context = this;
            callbacks.depth = 0;
        }
        // Push to callback array
        callbacks.push(fn);
    }
139282
def check_events(self):
        ''''''
        while self.event_count() > 0:
            event = self.get_event()
            for callback in self._callbacks:
                callback(event)
308615
def emit(self, event, *args, **kwargs):
        
        callbacks = self._callbacks.get(event, [])
        # Call the last callback if this is a single event.
        single = kwargs.pop('single', None)
        if single and callbacks:
            return callbacks[-1](*args, **kwargs)
        # Otherwise, return the list of callback outputs.
        res = []
        for callback in callbacks:
            res.append(callback(*args, **kwargs))
        return res
525758
function _addEvent(object, type, callback) {
        if (object.addEventListener) {
            object.addEventListener(type, callback, false);
            return;
        }

        object.attachEvent('on' + type, callback);
    }
790458
function (object, event, callback) {
        var index = this.indexOf(object);
        var listener = this.listeners[index];
        if (!listener) {
            listener = {
                'object': object,
                'events': {}
            };
            this.listeners.push(listener);
        }

        var callbacks = listener.events[event];
        if (!callbacks) {
            callbacks = [];
            listener.events[event] = callbacks;
        }

        // add the callback if it does not yet exist
        if (callbacks.indexOf(callback) == -1) {
            callbacks.push(callback);
        }
    }
158727
def _modify_event(self, event_name, method, func):
        
        if event_name not in self.ALL_EVENTS:
            raise TypeError(('event_name ("%s") can only be one of the '
                             'following: %s') % (event_name,
                                                 repr(self.ALL_EVENTS)))
        if not isinstance(func, collections.Callable):
            raise TypeError(('func must be callable to be added as an '
                             'observer.'))
        getattr(self._events[event_name], method)(func)
276973
def support_event_list_simple(fn):
    
    @wraps(fn)
    def _wrapped(self, event, *args, **kwargs):
        if _is_event_list(event):
            result = []
            for e in event:
                ret = fn(self, e, *args, **kwargs)

                if ret is None:
                    continue

                if isinstance(ret, (tuple, list)):
                    result.extend(ret)
                else:
                    result.append(ret)

            if result:
                if len(result) == 1:
                    return result[0]
                return result
            return None
        else:
            return fn(self, event, *args, **kwargs)

    return _wrapped
670893
def append(event, method = nil, oneshot = false, &block)
      callback = Callback.new(self, event, method||block, oneshot)
      (@listeners[event] ||= []) << callback
      callback
    end
695574
function() {

    this.on = this.addEventListener = function(type, listener) {
        if (!this.events[type]) {
            this.events[type] = [];
        }

        this.events[type].push(listener);
    };

    this.off = this.removeEventListener = function (type, listener) {
        if (!!this.events[type]) {
            for(var i = 0; i < this.events[type].length; i++) {
                if (this.events[type][i] === listener) {
                    this.events[type][i] = null;
                    this.events[type].splice(i, 1);
                    return;
                }
            }
        }
    };

    this.removeAllListeners = function (type) {
        this.events[type] = [];
    };

    var emit = function(cb, event) {
        // Handle callbacks asynchronously
        setTimeout(function() {
            cb(event);
        }, 0);

    };

    this.dispatchEvent = function (event) {
        if (!!event.type) {
            var type = event.type;
            if (!!this.events[type]) {
                event.target = this;
                for (var i = 0; i < this.events[type].length && (event.returnValue === undefined || event.returnValue) ; i++) {
                    var cb = this.events[type][i];
                    // Dereference cb for async
                    emit(cb.bind(event.target), event);
                }
            }
        }
    };
}
268108
function AddCallback(mesgId, callbackFunction, callbackTimeout) {
    var callbackElement, now;

    now = new Date().getTime();

    callbackElement = {
        id      :   mesgId,
        func    :   callbackFunction,
        timeout :   now + callbackTimeout
    };

    callbackList.push(callbackElement);
}
730885
function Callbacks( once ) {
        var list = [],
            stack = !once && [],
            fire = function( data ) {
                memory = data;
                fired = true;
                firingIndex = firingStart || 0;
                firingStart = 0;
                firingLength = list.length;
                firing = true;

                for ( ; list && firingIndex < firingLength; firingIndex++ ) {
                    list[ firingIndex ].apply( data[ 0 ], data[ 1 ] );
                }
                firing = false;

                if ( list ) {
                    if ( stack ) {
                        stack.length && fire( stack.shift() );
                    }  else {
                        list = [];
                    }
                }
            },
            self = {
                add: function() {
                    if ( list ) {
                        var start = list.length;
                        (function add ( args ) {
                            $.each( args, function( _, arg ) {
                                var type = $.type( arg );
                                if ( type === 'function' ) {
                                    list.push( arg );
                                } else if ( arg && arg.length &&
                                        type !== 'string' ) {

                                    add( arg );
                                }
                            });
                        })( arguments );

                        if ( firing ) {
                            firingLength = list.length;
                        } else if ( memory ) {
                            firingStart = start;
                            fire( memory );
                        }
                    }
                    return this;
                },

                disable: function() {
                    list = stack = memory = undefined;
                    return this;
                },

                // Lock the list in its current state
                lock: function() {
                    stack = undefined;
                    if ( !memory ) {
                        self.disable();
                    }
                    return this;
                },

                fireWith: function( context, args ) {
                    if ( list && (!fired || stack) ) {
                        args = args || [];
                        args = [ context, args.slice ? args.slice() : args ];
                        if ( firing ) {
                            stack.push( args );
                        } else {
                            fire( args );
                        }
                    }
                    return this;
                },

                fire: function() {
                    self.fireWith( this, arguments );
                    return this;
                }
            },

            fired, firing, firingStart, firingLength, firingIndex, memory;

        return self;
    }
278341
def bind(self, event_name, callback, *args, **kwargs):
        
        self.event_callbacks[event_name].append((callback, args, kwargs))
601504
def _event_funcs(self, event: str) -> Iterable[Callable]:
        
        for func in self._events[event]:
            yield func
11906
function addEvent(el, e, callback, capture) {
    if (el.addEventListener) {
      el.addEventListener(e, callback, capture || false);
    }
    else
      if (el.attachEvent) {
        el.attachEvent('on' + e, callback);
      }
  }
1030480
def add_done_callback(self, function, **kwargs):
        
        with self._callbacks_lock:
            _function = functools.partial(function, **kwargs)
            self._done_callbacks.append(_function)
1113581
def add_callback(self, callback=None, errorback=None):
        
        self._callback = callback
        self._errorback = errorback
239823
function addLoadEvent (func) {

        if (window.attachEvent) {
            return window.attachEvent('onload', func);
        }

        if (window.addEventListener) {
            return window.addEventListener('load', func, false);
        }

        return document.addEventListener('load', func, false);

    }