generateProxy receives a node to dispatch the event
557816
function dispatchPointerLeave(currentTarget, relatedTarget, generateProxy) {
        var commonParent = getFirstCommonNode(currentTarget, relatedTarget);
        var node = currentTarget;
        while (node && node !== commonParent) {//target range: this to the direct child of parent relatedTarget
            if (checkEventRegistration(node, 'pointerleave'))//check if any parent node has pointerleave
                generateProxy(node);
            node = node.parentNode;
        }
    }
424117
def _dispatch(request, *args)
      raise ArgumentError, "Invalid request #{request.inspect}" if not request.to_s =~ /\A(#{Node::NAME_REGEXP})(\?{,1})\z/
      node_name = $1.to_sym
      is_question = ($2 != "")

      node = @instance.find_local_node(node_name, @parent)

      # NOTE: Method return result.
      if node
        if is_question
          # Help request.
          out = [
            node.brief_desc || @instance.conf.brief_desc_stub,
            (["", node.full_desc] if node.full_desc),
          ].flatten(1).compact

          # `out` are lines of text, eventually.
          ::Kernel.puts out.empty?? "No description, please provide one" : out

          # For groups list contents after description.
          #if node.is_a? Node::Group
          #  ::Kernel.puts ["", self.class.new(@instance, node).inspect]
          #end
        else
          # Group/hack request.
          case node
          when Node::Group
            # Create and return a new nested access context.
            self.class.new(@instance, node)
          when Node::Hack
            # Invoke hack in the context of `HackTree` instance.
            @instance.instance_exec(*args, &node.block)
          else
            raise "Unknown node class #{node.class}, SE"
          end
        end # if is_question
      else
        ::Kernel.puts "Node not found: '#{node_name}'"
      end
    end
1321369
function EventDispatcher (tree, definition) {
  if (!tree || !_.isObject(tree) || !_.isFunction(tree.getViewBuilders)) {
    var err = new Error('Please pass a valid tree!');
    debug(err);
    throw err;
  }

  if (!definition || !_.isObject(definition)) {
    var err = new Error('Please pass a valid command definition!');
    debug(err);
    throw err;
  }

  this.tree = tree;

  this.definition = {
    correlationId: 'correlationId', // optional
    id: 'id',                       // optional
    name: 'name',                   // optional
//      aggregateId: 'aggregate.id',    // optional
//      context: 'context.name',        // optional
//      aggregate: 'aggregate.name',    // optional
    payload: 'payload'              // optional
//      revision: 'revision'            // optional
//      version: 'version',             // optional
//      meta: 'meta'                    // optional, if defined theses values will be copied to the notification (can be used to transport information like userId, etc..)
  };

  this.definition = _.defaults(definition, this.definition);
}
608337
function fire (event, $el, evt) {
    var handler = $el.data('dragon-opts')[event];
    // Patch the proxied Event Object
    evt.target = $el[0];
    if (handler) {
      handler(evt);
    }

    $el.trigger(event);
  }
1317551
private void processEvent(EventModel<?> event) {
        if (!event.getSource().isCreatedFromInstance()) {
            error("event: " + event + "has invalid source");
            return;
        }
        debug("EventFired: " + event.toString() + " from " + event.getSource().getID());
        submit(() -> event.lifecycleCallback(EventLifeCycle.START));

        if (checkEventsControllers(event)) {
            submit(() -> event.lifecycleCallback(EventLifeCycle.APPROVED));
            submit(() -> event.lifecycleCallback(EventLifeCycle.RESOURCE));
            List<ResourceModel> resourceList = getMain().getResourceManager().generateResources(event);
            event.addResources(resourceList);
            submit(() -> event.lifecycleCallback(EventLifeCycle.LISTENERS));
            List<EventListenerModel> listenersTemp = event.getAllInformations().parallelStream()
                    .map(listeners::get)
                    .filter(Objects::nonNull)
                    .flatMap(Collection::stream)
                    .distinct()
                    .collect(Collectors.toList());

            List<CompletableFuture> futures = listenersTemp.stream()
                    .map(eventListener -> submit(() -> eventListener.eventFired(event)))
                    .collect(Collectors.toList());
            try {
                timeOut(futures, 1000);
            } catch (InterruptedException e) {
                error("interrupted", e);
            }
            submit(() -> event.lifecycleCallback(EventLifeCycle.OUTPUT));
            getMain().getOutputManager().passDataToOutputPlugins(event);
            submit(() -> event.lifecycleCallback(EventLifeCycle.ENDED));
            List<EventListenerModel> finishListenersTemp = event.getAllInformations().parallelStream()
                    .map(finishListeners::get)
                    .filter(Objects::nonNull)
                    .flatMap(Collection::stream)
                    .distinct()
                    .collect(Collectors.toList());

            futures = finishListenersTemp.stream()
                    .map(eventListener -> submit(() -> eventListener.eventFired(event)))
                    .collect(Collectors.toList());

            try {
                timeOut(futures, 1000);
            } catch (InterruptedException e) {
                error("interrupted", e);
            }
        } else {
            debug("canceling: " + event.toString() + " from " + event.getSource().getID());
            submit(() -> event.lifecycleCallback(EventLifeCycle.CANCELED));
        }
    }
197538
protected void processEvent (DEvent event)
    {
        // look up the target object
        DObject target = _objects.get(event.getTargetOid());
        if (target == null) {
            log.debug("Event target no longer exists", "event", event);
            return;
        }

        // check the event's permissions
        if (!target.checkPermissions(event)) {
            log.warning("Event failed permissions check", "event", event, "target", target);
            return;
        }

        if (dispatchEvent(event, target)) {
            // unless requested not to, notify any proxies
            target.notifyProxies(event);
        }
    }
526499
def dispatchEvent(self, event, *args):
        
        for callback in self.listeners[event]:
            yield callback(event, self, *args)
412202
def _dispatch_event(self, event: LutronEvent, params: Dict):
    """"""
    for handler, context in self._subscribers:
      handler(self, context, event, params)
1189400
function Dispatcher() {
  let lastId = 1;
  let prefix = "ID_";
  let callbacks = {};
  let isPending = {};
  let isHandled = {};
  let isDispatching = false;
  let pendingPayload = null;

  function invokeCallback(id) {
    isPending[id] = true;
    callbacks[id](pendingPayload);
    isHandled[id] = true;
  }

  this.register = callback => {
    let id = prefix + lastId++;
    callbacks[id] = callback;
    return id;
  };

  this.unregister = id => {
    if (!callbacks.hasOwnProperty(id))
      return new Error("Cannot unregister unknown ID!");
    delete callbacks[id];
    return id;
  };

  this.waitFor = ids => {
    for (var i = 0; i < ids.length; i++) {
      var id = ids[id];
      if (isPending[id]) {
        return new Error("Circular dependency waiting for " + id);
      }

      if (!callbacks[id]) {
        return new Error(`waitFor: ${id} is not a registered callback.`);
      }

      invokeCallback(id);
    }

    return undefined;
  };

  this.dispatch = payload => {
    if (isDispatching) return new Error("Cannot dispatch while dispatching.");

    // start
    for (var id in callbacks) {
      isPending[id] = false;
      isHandled[id] = false;
    }

    pendingPayload = payload;
    isDispatching = true;

    // run each callback.
    try {
      for (var id in callbacks) {
        if (isPending[id]) continue;
        invokeCallback(id);
      }
    } finally {
      pendingPayload = null;
      isDispatching = false;
    }

    return payload;
  };
}
130144
function connectToPeer (event) {
  const multiaddr = $multiaddrInput.value

  if (!multiaddr) {
    return onError('No multiaddr was inserted.')
  }

  node.swarm.connect(multiaddr)
    .then(() => {
      onSuccess(`Successfully connected to peer.`)
      $multiaddrInput.value = ''
    })
    .catch(() => onError('An error occurred when connecting to the peer.'))
}
595757
function dispatchCustomEvent(node, type) {
	const event = document.createEvent('CustomEvent');

	event.initCustomEvent(type, true, true, undefined);

	node.dispatchEvent(event);
}
1106267
function forEachEventDispatch(event, cb) {
  var dispatchListeners = event._dispatchListeners;
  var dispatchIDs = event._dispatchIDs;
  if ("production" !== "development") {
    validateEventDispatches(event);
  }
  if (Array.isArray(dispatchListeners)) {
    for (var i = 0; i < dispatchListeners.length; i++) {
      if (event.isPropagationStopped()) {
        break;
      }
      // Listeners and IDs are two parallel arrays that are always in sync.
      cb(event, dispatchListeners[i], dispatchIDs[i]);
    }
  } else if (dispatchListeners) {
    cb(event, dispatchListeners, dispatchIDs);
  }
}
174986
@Override
    public synchronized void dispatch(@NonNull Event event) {
        String type = event.type;
        List<EventHandlerWrapper> eventHandlers = subscribers.get(type);
        if (eventHandlers != null) {
            EventHandlerWrapper handler = null;
            for (int i = 0, size = eventHandlers.size(); i < size; i++) {
                handler = eventHandlers.get(i);
                if (handler.eventHandlerReceiver != null) {
                    handler.handleEvent(event);
                } else {
                    if (!TextUtils.isEmpty(handler.producer) && handler.producer.equals(event.sourceId)
                            || TextUtils.isEmpty(handler.producer)) {
                        handler.handleEvent(event);
                    }
                }
            }
        }
    }
91301
private static void generateToCConnection(Map<String, List<TraceEvent>> events, FileWriter fw)
      throws Exception
   {
      writeString(fw, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
      writeEOL(fw);
      writeString(fw, "                      \"http://www.w3.org/TR/html4/loose.dtd\">");
      writeEOL(fw);

      writeString(fw, "<html>");
      writeEOL(fw);

      writeString(fw, "<head>");
      writeEOL(fw);

      writeString(fw, "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">");
      writeEOL(fw);

      writeString(fw, "<title>Reference: Connection</title>");
      writeEOL(fw);

      writeString(fw, "</head>");
      writeEOL(fw);

      writeString(fw, "<body style=\"background: #D7D7D7;\">");
      writeEOL(fw);

      writeString(fw, "<h1>Reference: Connection</h1>");
      writeEOL(fw);

      writeString(fw, "<ul>");
      writeEOL(fw);

      for (String id : events.keySet())
      {
         writeString(fw, "<li><a href=\"#" + id + "\">" + id + "</a></li>");
         writeEOL(fw);
      }

      writeString(fw, "</ul>");
      writeEOL(fw);

      for (Map.Entry<String, List<TraceEvent>> entry : events.entrySet())
      {
         writeString(fw, "<a name=\"" + entry.getKey() + "\"><h2>" + entry.getKey() + "</h2></a>");
         writeEOL(fw);

         writeString(fw, "<table>");
         writeEOL(fw);
      
         writeString(fw, "<tr>");
         writeEOL(fw);

         writeString(fw, "<td><b>Timestamp</b></td>");
         writeEOL(fw);

         writeString(fw, "<td><b>ConnectionListener</b></td>");
         writeEOL(fw);

         writeString(fw, "<td><b>ManagedConnectionPool</b></td>");
         writeEOL(fw);

         writeString(fw, "<td><b>Pool</b></td>");
         writeEOL(fw);

         writeString(fw, "</tr>");
         writeEOL(fw);

         for (TraceEvent te : entry.getValue())
         {
            writeString(fw, "<tr>");
            writeEOL(fw);

            writeString(fw, "<td>" + te.getTimestamp() + "</td>");
            writeEOL(fw);
      
            writeString(fw, "<td><a href=\"" + te.getPool() + "/" + te.getConnectionListener() + "/index.html\">" +
                        te.getConnectionListener() + "</a></td>");
            writeEOL(fw);
         
            writeString(fw, "<td>" + te.getManagedConnectionPool() + "</td>");
            writeEOL(fw);
      
            writeString(fw, "<td><a href=\"" + te.getPool() + "/index.html\">" + te.getPool() + "</a></td>");
            writeEOL(fw);
      
            writeString(fw, "</tr>");
            writeEOL(fw);
         }
         
         writeString(fw, "</table>");
         writeEOL(fw);

         writeString(fw, "<p>");
         writeEOL(fw);
      }

      writeString(fw, "<p>");
      writeEOL(fw);

      writeString(fw, "<a href=\"index.html\">Back</a>");
      writeEOL(fw);

      writeString(fw, "</body>");
      writeEOL(fw);

      writeString(fw, "</html>");
      writeEOL(fw);
   }
982614
def _dispatcher(self, connection, event):
        
        super(BaseBot, self)._dispatcher(connection, event)
        for handler in self.events[event.eventtype()]:
            handler(self, connection, event)
356304
function proxy (frontend, backend, capture){
  switch(frontend.type+'/'+backend.type){
    case 'push/pull':
    case 'pull/push':
    case 'xpub/xsub':
      if(capture){

        frontend.on('message',function (){
          backend.send([].slice.call(arguments));
        });

        backend.on('message',function (){
          frontend.send([].slice.call(arguments));

          //forwarding messages over capture socket
          capture.send([].slice.call(arguments));
        });

      } else {

        //no capture socket provided, just forwarding msgs to respective sockets
        frontend.on('message',function (){
          backend.send([].slice.call(arguments));
        });

        backend.on('message',function (){
          frontend.send([].slice.call(arguments));
        });

      }
      break;
    case 'router/dealer':
    case 'xrep/xreq':
      if(capture){

        //forwarding router/dealer pack signature: id, delimiter, msg
        frontend.on('message',function (id,delimiter,msg){
          backend.send([].slice.call(arguments));
        });

        backend.on('message',function (id,delimiter,msg){
          frontend.send([].slice.call(arguments));

          //forwarding message to the capture socket
          capture.send([].slice.call(arguments, 2));
        });

      } else {

        //forwarding router/dealer signatures without capture
        frontend.on('message',function (id,delimiter,msg){
          backend.send([].slice.call(arguments));
        });

        backend.on('message',function (id,delimiter,msg){
          frontend.send([].slice.call(arguments));
        });

      }
      break;
    default:
      throw new Error('wrong socket order to proxy');
  }
}
718682
public void dispatchEvent(Event event, String eventName) {
    int typeInt = Event.getTypeInt(eventName);
    Object[] handlerData = $(element).data(EVENT_DATA);
    for (int i = 0, l = elementEvents.length(); i < l; i++) {
      BindFunction listener = elementEvents.get(i);
      String namespace = JsUtils.prop(event, "namespace");
      boolean matchEV = listener != null && (listener.hasEventType(typeInt) || listener.isTypeOf(eventName));
      boolean matchNS = matchEV && (isNullOrEmpty(namespace) || listener.nameSpace.equals(namespace));
      if (matchEV && matchNS) {
        if (!listener.fire(event, typeInt, eventName, handlerData)) {
          event.stopPropagation();
          event.preventDefault();
        }
      }
    }
  }