setup event listeners and notification system for events
352321
function setupEvent(element, eType, handler, capture) {
  notifyOfNextSubs[eType] = [];
  subsIDs[eType] = {};
  element.addEventListener(
    eType,
    handler,
    passiveEventSupport
      ? {
          capture,
          // don't set click listener as passive because syntheticClick may call preventDefault
          passive: eType !== 'click',
        }
      : capture,
  );
}
864685
private function registerEventListeners()
    {
        $listeners = $this->getListeners();
        foreach ($listeners as $listenerKey => $listenerValues) {
            foreach ($listenerValues as $listenerValue) {
                \Event::listen($listenerKey,
                    $listenerValue
                );
            }
        }
    }
868380
function on(priv, eventName, listener) {
  check(eventName, 'eventName').is.aString.and.oneOf(EVENT_NAMES)();
  check(listener, 'listener').is.aFunction();

  getListeners(priv, eventName).push(listener);
}
110471
function _addListeners() {
        // Avoid adding duplicate listeners - e.g. if a 2nd search is run without closing the old results panel first
        _removeListeners();

        DocumentModule.on("documentChange", _documentChangeHandler);
        FileSystem.on("change", _debouncedFileSystemChangeHandler);
        DocumentManager.on("fileNameChange",  _fileNameChangeHandler);
    }
1042646
function addWindowEventListeners() {
            if(window.onMouseDown){
                mouse.addEventListener(MouseEvent.MOUSE_DOWN, window.onMouseDown.bind(window));
            }
            if(window.onMouseUp){
                mouse.addEventListener(MouseEvent.MOUSE_UP, window.onMouseUp.bind(window));
            }
            if(window.onMouseMove){
                mouse.addEventListener(MouseEvent.MOUSE_MOVE, window.onMouseMove.bind(window));
            }
            if(window.onMouseDrag){
                mouse.addEventListener(MouseEvent.MOUSE_DRAG, window.onMouseDrag.bind(window));
            }
            if(window.onMouseScroll){
                mouse.addEventListener(MouseEvent.MOUSE_SCROLL, window.onMouseScroll.bind(window));
            }


            if(window.onKeyDown){
                keyboard.addEventListener(KeyboardEvent.KEY_DOWN, window.onKeyDown.bind(window));
            }
            if(window.onKeyPress){
                keyboard.addEventListener(KeyboardEvent.KEY_PRESS, window.onKeyPress.bind(window));
            }
            if(window.onKeyUp){
                keyboard.addEventListener(KeyboardEvent.KEY_UP, window.onKeyUp.bind(window));
            }
            if(window.onWindowResize) {
                window.addEventListener(WindowEvent.WINDOW_RESIZE, window.onWindowResize.bind(window));
            }
        }
768797
public function notifyListeners() {

        foreach ($this->listeners as $listener) {

            $listenerClass = $listener['listener'];
            $handler = array($listenerClass, 'on_' . $this->state);
            if(!class_exists($listenerClass)) {
                throw new \Exception($listenerClass . ' does not exist');
            }

            if ($this->state == $listener['event'] && is_callable($handler)) {
                unset($listener['listener']);     
                
                $eventListener = new $listenerClass($this->logger, $this->request, $this->response);
                $eventListener->setDatasources($this->datasourceFactory, $this->datasources);
                $eventListener->setDatasourceKey($this->datasourceKey);
                $eventListener->setEventDispatcher($this->eventDispatcher);
                $eventListener->setConfig($listener);
                $eventListener->setCacheManager($this->cacheManager);
                $eventListener->setContainer($this->container);

                $eventListener->execute($this->state, $this->event);

            }
        }
      
     
    }
275138
public void notifyListeners (DEvent event)
    {
        if (_listeners == null) {
            return;
        }

        for (int ii = 0, ll = _listeners.length; ii < ll; ii++) {
            Object listener = _listeners[ii];
            if (listener == null) {
                continue;
            }
            if (listener instanceof WeakReference<?>) {
                if ((listener = ((WeakReference<?>)listener).get()) == null) {
                    _listeners[ii] = null;
                    continue;
                }
            }

            try {
                // do any event specific notifications
                event.notifyListener(listener);

                // and notify them if they are listening for all events
                if (listener instanceof EventListener) {
                    ((EventListener)listener).eventReceived(event);
                }

            } catch (Exception e) {
                log.warning("Listener choked during notification", "list", listener,
                            "event", event, e);
            }
        }
    }
194195
protected function bindEvents(): void
    {
        $userConfig = $this->app['config'][static::$abstract];

        $handler = new EventHandler($this->app->events, $userConfig);

        $handler->subscribe();

        $handler->subscribeQueueEvents($this->app->queue);

        if (isset($userConfig['send_default_pii']) && $userConfig['send_default_pii'] !== false) {
            $handler->subscribeAuthEvents();
        }
    }
241399
function addListener(event, callback, meta) {
  event.listeners.push(callback);
  event.meta.set(callback, meta);
}
238895
function listenersHelp (element, events, handler, method) {
  let list = events.split(' ')
  for (let i = 0, len = list.length; i < len; i++) {
    let item = list[i]
    if (method === false) {
      element.removeEventListener(item, handler)
    } else {
      element.addEventListener(item, handler, false)
    }
  }
}
1273630
function registerListeners(scope, listeners) {
        var fns = [];

        for (var name in listeners) {
            if (listeners.hasOwnProperty(name) && listeners[name]) {
                fns.push(eventBus.on(name, $injector.invoke(listeners[name])));
            }
        }

        // make sure handlers are destroyed along with scope
        scope.$on('$destroy', function () {
            for (var i = 0; i < fns.length; i++) {
                fns[i]();
            }
        });
    }
698605
function Notification(options) {
  ui.Emitter.call(this);
  options = options || {};
  this.template = html;
  this.el = $(this.template);
  this.render(options);
  if (Notification.effect) this.effect(Notification.effect);
}
915126
private function populateListeners()
    {
        if (isset($GLOBALS['TL_EVENTS']) && is_array($GLOBALS['TL_EVENTS'])) {
            $this->addListeners($GLOBALS['TL_EVENTS']);
        }

        foreach ($this->listenerFiles as $file) {
            // @codeCoverageIgnoreStart
            $events = (array) include $file;
            $this->addListeners($events);
            // @codeCoverageIgnoreEnd
        }
    }
45262
def _register_event_listeners(self, cls):
        
        event.listen(cls, 'after_insert', self._new_listener)
        event.listen(cls, 'after_update', self._update_listener)
        event.listen(cls, 'after_delete', self._delete_listener)
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);
                }
            }
        }
    };
}
560842
function on(eventName, handler, context, args, once) {
    this.__listeners = this.__listeners || {};
    this.__listeners[eventName] = this.__listeners[eventName] || [];
    this.__listeners[eventName].push({
        fn: handler,
        context: context,
        args: args,
        once: !!once
    });
}
1337077
protected void notifyListeners() {
		Iterator it = listeners.iterator();
		while (it.hasNext()) {
			((ComponentListener) it.next()).componentActivated(this);
		}
	}