Applies all middleware functions registered against the given
        event in order to the given document.
4856
def apply(self, event, document, *args, **kwargs):
        
        for fn in self._handler_dict.get(event, []):
            fn(document, *args, **kwargs)
452427
function on(evt, handler) {
            var _this = this;

            var thisArg = arguments[2] === undefined ? null : arguments[2];

            // if multiple events are passed, call our utility method `eachEvt` to deal with this.
            // if it returns `true`, we should exit, because we're actually being called recursively.
            // If it returns `false`, we're not being called with multiple parameters (this time, anyway),
            // and so can continue processing.
            if (eachEvt(evt, handler, thisArg, function () {
                for (var _len2 = arguments.length, _ = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
                    _[_key2] = arguments[_key2];
                }

                return _this.on.apply(_this, _);
            })) {
                return this;
            } // simplify typing; eH = eventHandlers
            var eH = this[_eventHandlers];

            if (!eH.has(evt)) {
                // if we don't have an event category already in the map, create it as a new map
                // this map will be of the form bindingObject:methods.
                eH.set(evt, new core.Map());
            }

            // simplify typing; objMap == objectMap (bindingObject:methods)
            var objMap = eH.get(evt);

            if (!objMap.has(thisArg)) {
                // if we don't have `thisArg` in the map, make a set for it. The set is the set of functions
                // and we use a set so as to prevent duplicates automatically.
                objMap.set(thisArg, new core.Set());
            }
            var handlerSet = objMap.get(thisArg);

            if (typeof handler === "function") {
                // add the handler
                handlerSet.add(handler);
            } else {
                // a little error checking!
                throw new TypeError("Event handler must be a function.");
            }

            return this;
        }
1153264
function(event /* params */) {

            var listeners;
            var that = this;
            var params = _.toArray(arguments).slice(1);

            listeners = this.__getEventListeners(event);

            _.each(listeners, function(listener) {
                listener.apply(that, params);
            });

            listeners = this.__getEventListeners('event.emit');

            _.each(listeners, function(listener) {
                listener.call(that, event, params);
            });

            return this;
        }
842420
def trigger (self, event, *args, **kwargs):
        
        if self._events.has_key(event):
            for _callback in self._events[event]:
                try:
                    _callback(args, kwargs)
                except TypeError:
                    _callback()
945773
function use(events, middleware)
{
  // if no middleware supplied assume it's single argument call
  if (!middleware)
  {
    middleware = events;
    events     = null;
  }

  // make it uniform
  events = normalizeEvents(events);

  // store middleware per event
  events.forEach(function(e)
  {
    // bind middleware to the current context
    (this._stack[e] = this._stack[e] || []).push(middleware.bind(this));

    // make mark in history
    this.logger.debug({message: 'Added middleware to the stack', event: e, middleware: middleware});
  }.bind(this));
}
1050473
function apply(api, _global) {
    var WS = _global.WebSocket;
    // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener
    // On older Chrome, no need since EventTarget was already patched
    if (!_global.EventTarget) {
        patchEventTarget(_global, [WS.prototype]);
    }
    _global.WebSocket = function (x, y) {
        var socket = arguments.length > 1 ? new WS(x, y) : new WS(x);
        var proxySocket;
        var proxySocketProto;
        // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance
        var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage');
        if (onmessageDesc && onmessageDesc.configurable === false) {
            proxySocket = ObjectCreate(socket);
            // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror'
            // but proxySocket not, so we will keep socket as prototype and pass it to
            // patchOnProperties method
            proxySocketProto = socket;
            [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) {
                proxySocket[propName] = function () {
                    var args = ArraySlice.call(arguments);
                    if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) {
                        var eventName = args.length > 0 ? args[0] : undefined;
                        if (eventName) {
                            var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName);
                            socket[propertySymbol] = proxySocket[propertySymbol];
                        }
                    }
                    return socket[propName].apply(socket, args);
                };
            });
        }
        else {
            // we can patch the real socket
            proxySocket = socket;
        }
        patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto);
        return proxySocket;
    };
    var globalWebSocket = _global['WebSocket'];
    for (var prop in WS) {
        globalWebSocket[prop] = WS[prop];
    }
}
21035
function transform(context, file, fileSet, next) {
  if (stats(file).fatal) {
    next()
  } else {
    debug('Transforming document `%s`', file.path)
    context.processor.run(context.tree, file, onrun)
  }

  function onrun(error, node) {
    debug('Transformed document (error: %s)', error)
    context.tree = node
    next(error)
  }
}
495969
function applyEventStrategy(strategy, event) {
  const request = event.request;
  switch (strategy.type) {
    case 'offline-only':
      return fetchAndCache(request, strategy)().catch(getFromCache(request));
    case 'fallback-only':
      return fetchAndCache(request, strategy)().then(fallbackToCache(request));
    case 'prefer-cache':
      return getFromCache(request)().catch(fetchAndCache(request, strategy));
    case 'race':
      return getFromFastest(request, strategy)();
    default:
      return Promise.reject(`Strategy not supported: ${strategy.type}`);
  }
}
299849
function startListeningForEvent(eventName, namespace) {
    document.documentElement.addEventListener(eventNameMapping[eventName] || eventName, handleEvent.bind(null, namespace, "data-" + namespace + "-name", getEventRegistry(namespace)[eventName]));
}
250318
private ChangeEvent<BsonDocument> getSynthesizedRemoteChangeEventForDocument(
      final MongoNamespace ns,
      final BsonValue documentId,
      final BsonDocument document
  ) {
    // a. When the document is looked up, if it cannot be found the synthesized change event is a
    // DELETE, otherwise it's a REPLACE.
    if (document == null) {
      return ChangeEvents.changeEventForLocalDelete(ns, documentId, false);
    }
    return ChangeEvents.changeEventForLocalReplace(ns, documentId, document, false);
  }
46768
private function applyRegistrationCallbacks(Event $event)
    {
        foreach ($this->registrationCallbacks as $callback) {
            $event = $callback->onEventRegistration($event);
        }

        return $event;
    }
236970
function on(dom, eventType, callback) {
  if (document.addEventListener) {
    dom.addEventListener(eventType, callback);
  } else {
    dom.attachEvent('on' + eventType, callback);
  }
}
727060
function(names, _maybePrevented){
			if (!document.addEventListener) {
				return;
			}
			if (typeof names == 'string') {
				names = [names];
			}
			$.each(names, function(i, name){
				var handler = function(e){
					e = $.event.fix(e);
					if (_maybePrevented && webshims.capturingEventPrevented) {
						webshims.capturingEventPrevented(e);
					}
					return $.event.dispatch.call(this, e);
				};
				special[name] = special[name] || {};
				if (special[name].setup || special[name].teardown) {
					return;
				}
				$.extend(special[name], {
					setup: function(){
						this.addEventListener(name, handler, true);
					},
					teardown: function(){
						this.removeEventListener(name, handler, true);
					}
				});
			});
		}
102255
function() {
		// If running in Node.js, don't teardown.
		if(isNode()) {
			return;
		}

		var document = getDocument(),
			window = getGlobal();

		domEvents.removeDelegateListener(document.documentElement, "click", "a", this.anchorClickHandler);

		// Reset the changed `window.history` methods to their original values.
		canReflect.eachKey(methodsToOverwrite, function(method) {
			window.history[method] = this.originalMethods[method];
		}, this);

		domEvents.removeEventListener(window, "popstate", this.dispatchHandlers);
	}
1125263
function iterateEvents(target, entity, bindings, functionCallback, stringCallback){
    if (!entity || !bindings) { return; }

    // allow the bindings to be a function
    if (_.isFunction(bindings)){
      bindings = bindings.call(target);
    }

    // iterate the bindings and bind them
    _.each(bindings, function(methods, evt){

      // allow for a function as the handler, 
      // or a list of event names as a string
      if (_.isFunction(methods)){
        functionCallback(target, entity, evt, methods);
      } else {
        stringCallback(target, entity, evt, methods);
      }

    });
  }
925284
def dispatch(self, event):
        

        for event_types, queues in self.queues.items():
            if event.type & event_types:
                for queue in queues:
                    queue.put(event)
1313629
function(event, ui){

	    // Prevent default selection input filling action (from
	    // jQuery UI) when non-default marked.
	    if( ! anchor._fill_p ){
		event.preventDefault();		
	    }

	    var doc_to_apply = null;
	    if( ui.item ){
		doc_to_apply = ui.item.document;
	    }

	    // Only do the callback if it is defined.
	    if( doc_to_apply && 
		bbop.core.is_defined(anchor._list_select_callback) ){
		anchor._list_select_callback(doc_to_apply);
	    }
	}