When we get an 'event' type from the bridge
        handle it by invoking the handler and if needed
        sending back the result.
967203
def handle_event(self, event):
        
        result_id, ptr, method, args = event[1]
        obj = None
        result = None
        try:
            obj, handler = bridge.get_handler(ptr, method)
            result = handler(*[v for t, v in args])
        except bridge.BridgeReferenceError as e:
            #: Log the event, don't blow up here
            msg = "Error processing event: {} - {}".format(
                  event, e).encode("utf-8")
            print(msg)
            self.show_error(msg)
        except:
            #: Log the event, blow up in user's face
            msg = "Error processing event: {} - {}".format(
                  event, traceback.format_exc()).encode("utf-8")
            print(msg)
            self.show_error(msg)
            raise
        finally:
            if result_id:
                if hasattr(obj, '__nativeclass__'):
                    sig = getattr(type(obj), method).__returns__
                else:
                    sig = type(result).__name__

                self.send_event(
                    bridge.Command.RESULT,  #: method
                    result_id,
                    bridge.msgpack_encoder(sig, result)  #: args
                )
1364003
function( event ) {
	event.type = event.data;
	jQuery.event.handle.apply( this, arguments );
}
432934
@Override
    public void handleResult(RHI result) {
        if (wrappedResultHandler != null) {
            wrappedResultHandler.handleResult(resultTransformer.transform(result));
        }
    }
584317
@Override protected void handleEvents(final String EVENT_TYPE) {
        super.handleEvents(EVENT_TYPE);
        if ("VISIBILITY".equals(EVENT_TYPE)) {
            Helper.enableNode(title, clock.isTitleVisible());
            Helper.enableNode(text, clock.isTextVisible());
            Helper.enableNode(dateText, clock.isDateVisible());
            Helper.enableNode(second, clock.isSecondsVisible());
        } else if ("FINISHED".equals(EVENT_TYPE)) {

        }
    }
1246085
protected void fireEvent(SerialPortEventTypes eventType) {
        executor.submit(new Runnable() {
            @Override
            public void run() {
                for (SerialPortEventListener listener : eventListeners) {
                    listener.serialEvent(new SerialPortEvent(eventType));
                }

            }
        });
    }
180841
function (eventType, event, target) {

                if (!(event instanceof EventDispatcher.Event)) {
                    event = new EventDispatcher.Event(event);
                }

                if (!event.target) {
                    event.target = target || this;
                }

                event.type = eventType;


                if (!(this._eventHandlers[eventType] || this._eventHandlers["*"])) {
                    return event;
                }

                var list,
                    result, i;

                if (this._eventHandlers[eventType]) {

                    list = this._eventHandlers[eventType].slice();
                    for (i = 0; i < list.length; i++) {
                        if (list[i]) {
                            result = list[i].trigger(event, event.target);
                            if (result !== undefinedValue) {

                                if (result === false) {
                                    event.preventDefault();
                                    event.stopPropagation();
                                }
                            }

                            if (event.isImmediatePropagationStopped) {
                                break;
                            }
                        }
                    }
                }

                if (this._eventHandlers["*"]) {

                    list = this._eventHandlers["*"].slice();
                    for (i = 0; i < list.length; i++) {
                        if (list[i]) {
                            result = list[i].trigger(event, target);
                            if (result !== undefinedValue) {

                                if (result === false) {
                                    event.preventDefault();
                                    event.stopPropagation();
                                }
                            }

                            if (event.isImmediatePropagationStopped) {
                                break;
                            }
                        }
                    }
                }

                return event;
            }
637515
def handle_event(event)
      if event.is_a?(Hash)
        if ["Push", "Request"].include?(event[:type])
          # Use next_tick to ensure that on main reactor thread
          # so that any data access is thread safe
          EM_S.next_tick do
            begin
              if (result = @dispatcher.dispatch(event_to_packet(event))) && event[:type] == "Request"
                @client.notify(result_to_event(result), [result.to])
              end
            rescue Dispatcher::DuplicateRequest
            rescue Exception => e
              ErrorTracker.log(self, "Failed sending response for <#{event[:uuid]}>", e)
            end
          end
        elsif event[:type] == "Result"
          if (data = event[:data]) && (result = data[:result]) && result.respond_to?(:non_delivery?) && result.non_delivery?
            Log.info("Non-delivery of event <#{data[:request_uuid]}>: #{result.content}")
          else
            ErrorTracker.log(self, "Unexpected Result event from #{event[:from]}: #{event.inspect}")
          end
        else
          ErrorTracker.log(self, "Unrecognized event type #{event[:type]} from #{event[:from]}")
        end
      else
        ErrorTracker.log(self, "Unrecognized event: #{event.class}")
      end
      nil
    end
203423
def result_to_event(result)
      { :type => "Result",
        :from => result.from,
        :data => {
          :result => result.results,
          :duration => result.duration,
          :request_uuid => result.token,
          :request_from => result.request_from } }
    end
1341356
function on(element, type, handler, opt) {
    util.addEventListener(element, type, handler, opt, true);
  }
576686
def trigger_event(self, event, client, args, force_dispatch=False):
        """"""
        self.controller.process_event(event, client, args, force_dispatch=force_dispatch)
323078
function( type, handler ) {

      if( handler === void 0 || handler === null )
        throw new Error( 'Missing argument "handler"' )

      if( typeof handler !== 'function' && typeof handler.handleEvent !== 'function' )
        throw new TypeError( 'Handler must be a function.' )

      this._events[ type ] ?
        this._events[ type ].push( handler ) :
        this._events[ type ] = [ handler ]

      if( Emitter.warn && this._events[ type ].length > this._maxListeners ) {
        if( this._maxListeners > 0 && !this._memLeakDetected ) {
          this._memLeakDetected = true
          console.warn(
            'WARNING: Possible event emitter memory leak detected.',
            this._events[ type ].length, 'event handlers added.',
            'Use emitter.setMaxListeners() to increase the threshold.'
          )
          console.trace()
        }
      }

      return this

    }
677990
protected void processResult(RO result) {
        for (ResultHandler<RO> resultHandler : resultHandlers) {
            resultHandler.handleResult(result);
        }
    }
1303095
def event_handler(self, event_type, src_path):
        
        filename = os.path.relpath(src_path, self.searchpath)
        if self.should_handle(event_type, src_path):
            print("%s %s" % (event_type, filename))
            if self.site.is_static(filename):
                files = self.site.get_dependencies(filename)
                self.site.copy_static(files)
            else:
                templates = self.site.get_dependencies(filename)
                self.site.render_templates(templates)
971339
def process_event(self, event, client, args, force_dispatch=False):
        
        if not self.running:
            _log.debug("Ignoring '%s' event - controller not running.", event)
            return

        # We keep a copy of the state of loaded modules before this event,
        # and restore it when we're done. This lets us handle events that
        # result in other events being dispatched in a graceful manner.
        old_loaded = self.loaded_on_this_event
        self.loaded_on_this_event = set(old_loaded or []) if not force_dispatch else set()

        try:
            _log.debug("Controller is dispatching '%s' event", event)
            for module_name in self.module_ordering:
                if module_name in self.loaded_on_this_event and not force_dispatch:
                    _log.debug("Not dispatching %s to '%s' because it was just "
                               "loaded (%r).", event, module_name,
                               self.loaded_on_this_event)
                    continue
                module = self.loaded_modules[module_name]
                if module.handle_event(event, client, args):
                    return True
        finally:
            self.loaded_on_this_event = old_loaded
218922
function _callHandler(handler) {
        try {
            // TODO (issue 1034): We *could* use a $.Deferred for this, except deferred objects enter a broken
            // state if any resolution callback throws an exception. Since third parties (e.g. extensions) may
            // add callbacks to this, we need to be robust to exceptions
            handler();
        } catch (e) {
            console.error("Exception when calling a 'brackets done loading' handler: " + e);
            console.log(e.stack);
        }
    }
580574
function (eventType, handler) {
		// simplest possible event model for internal use
		this.element['on' + eventType] = function () {
			var evt = win.event;
			evt.target = evt.srcElement;
			handler(evt);
		};
		return this;
	}
1029801
public function handleResult()
    {
        // No result
        $result = $this->worker->getResult();
        if ($result === null) {
            return;
        }

        // Invalid worker state, wait for a response first.
        if (!$this->isWorkerHandlerReady()) {
            return;
        }

        $this->sendToWorkerHandler(new Protocol\JobResult($this->worker->getRequestId(), $result));
        $this->worker->setState(Worker::RESULT);
    }