Register an event handler.

@param {String} event
@param {Function} handler
779039
function(event, handler) {
    return events.on({
      listeners: this._listeners,
      event: event,
      handler: handler
    });
  }
1320906
function handleEvent(handler, day, modifiers) {
  if (!handler) {
    return undefined;
  }
  return function (e) {
    e.persist();
    handler(day, modifiers, e);
  };
}
689316
def _register_handler(event, fun, external=False):
    """"""
    registry = core.HANDLER_REGISTRY
    if external:
        registry = core.EXTERNAL_HANDLER_REGISTRY

    if not isinstance(event, basestring):
        # If not basestring, it is a BaseEvent subclass.
        # This occurs when class methods are registered as handlers
        event = core.parse_event_to_name(event)

    if event in registry:
        registry[event].append(fun)
    else:
        registry[event] = [fun]
    return fun
495474
def register_handler(self, handler):
        
        self._handlers[handler.namespace] = handler

        handler.registered(self)
422414
function addEvent(eventName, {
    onElement,
    withCallback,
    avoidDuplicate = true,
    once = false,
    useCapture = false} = { }, thisArg) {
    let element = onElement || []
    if (utils.isString(element)) {
        element =  document.querySelectorAll(element)
    }
    function handler(event) {
        if (utils.isFunction(withCallback)) {
            withCallback.call(thisArg, event, this)
        }
        if (once) {
            handler.destroy();
        }
    }
    handler.destroy = function() {
        each(element, (el) => {
            const events = getNodeEvents(el, eventName, handler);
            if (events.found) { events.all.splice(events.evt, 1); }
            if (el.removeEventListener) el.removeEventListener(eventName, handler, useCapture)
        })
    }
    each(element, (el) => {
        const events = getNodeEvents(el, eventName, handler);
        if (el.addEventListener && (avoidDuplicate && !events.found) || !avoidDuplicate) {
            el.addEventListener(eventName, handler, useCapture)
            events.all.push({ eventName: eventName, fn: handler});
        }
    })
    return handler
}
1299602
function registerValueHandler (handlers, type, handler) {
  let typeofType = typeof type;

  if (typeofType !== 'function' && typeofType !== 'string') {
    throw new Error("type must be a class constructor or string");
  }

  if (typeof handler !== 'function') {
    throw new Error("handler must be a function");
  }

  for (let typeHandler of handlers) {
    if (typeHandler.type === type) {
      typeHandler.handler = handler;

      return;
    }
  }

  handlers.push({
    type: type,
    handler: handler,
  });
}
1231498
function (type, handler) {
        var handlers = this.handlers();
        if (handlers[type]) {
            throw new Error('The hook has already been registered, you can use only one hook for specific event type: ' + type + ', point.id:' + this._id);
        }
        handlers[type] = handler;
        this._handlersConfigured = true;
        return this;
    }
1292661
private function ensureCallback($handler, $event)
    {
        if (!is_callable($handler)) {
            if (is_object($handler)) {
                if (!$handler instanceof \Closure) {
                    $handler = [$handler, $event];
                }
            }
            if (!is_callable($handler)) {
                throw new EventHandlerException("Handler is not callable for event {$event}");
            }
        }

        return $handler;
    }
673406
def trigger(self, event, *args):
        """"""
        for handler in self._event_handlers[event]:
            handler(*args)
848820
function(type, handler)
	{
		var obj = this.__obj;
		
		if (obj)
		{
			switch (true)
			{
				// TODO Remove the last tiny piece of jQuery support?
				case conbo.$ && obj instanceof conbo.$:
				case window.$ && obj instanceof window.$:
				{
					obj.on(type, handler);
					break;
				}
				
				case obj instanceof conbo.EventDispatcher:
				{
					obj.addEventListener(type, handler);
					break;
				}
				
				default:
				{
					var types = type.split(' ');
					
					types.forEach(function(type)
					{
						obj.addEventListener(type, handler);
					});
				}
			}
		}
		
		return this;
	}
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();
        }
      }
    }
  }
815402
function( element, type, handler, useCapture )
    {
        if( element.addEventListener ) {
            element.addEventListener( type, handler, useCapture ? true : false );
        }
        else if( element.attachEvent ) {
            element.attachEvent( 'on' + type, handler );
        }
        else if( element != window )
            element['on' + type] = handler;
    }
1216651
function addHandler(node, eventType, handler, thisObject){
    node = getNode(node);

    if (!node)
      throw 'basis.event.addHandler: can\'t attach event listener to undefined';

    if (typeof handler != 'function')
      throw 'basis.event.addHandler: handler is not a function';

    var handlers = node === global ? globalEvents : node[EVENT_HOLDER];

    if (!handlers)
      handlers = node[EVENT_HOLDER] = {};

    var eventTypeHandlers = handlers[eventType];
    var handlerObject = {
      handler: handler,
      thisObject: thisObject
    };

    if (!eventTypeHandlers)
    {
      eventTypeHandlers = handlers[eventType] = [handlerObject];
      eventTypeHandlers.fireEvent = function(event){ // closure
        // simulate capture phase for old browsers
        event = wrap(event);
        if (noCaptureScheme && event && globalHandlers[eventType])
        {
          if (typeof event.returnValue == 'undefined')
          {
            observeGlobalEvents(event);
            if (event.cancelBubble === true)
              return;
            if (typeof event.returnValue == 'undefined')
              event.returnValue = true;
          }
        }

        startFrame(event);

        // call eventType handlers
        for (var i = 0, wrappedEvent = new Event(event), item; item = eventTypeHandlers[i++];)
          item.handler.call(item.thisObject, wrappedEvent);

        finishFrame(event);
      };

      if (W3CSUPPORT)
        // W3C DOM event model
        node.addEventListener(eventType, eventTypeHandlers.fireEvent, false);
      else
        // old IE event model
        node.attachEvent('on' + eventType, eventTypeHandlers.fireEvent);
    }
    else
    {
      // check for duplicates, exit if found
      for (var i = 0, item; item = eventTypeHandlers[i]; i++)
        if (item.handler === handler && item.thisObject === thisObject)
          return;

      // add only unique handlers
      eventTypeHandlers.push(handlerObject);
    }
  }
911529
function setEventHandler(name, handler, dom, tag) {
  var eventName,
    cb = handleEvent.bind(tag, dom, handler);

  // avoid to bind twice the same event
  // possible fix for #2332
  dom[name] = null;

  // normalize event name
  eventName = name.replace(RE_EVENTS_PREFIX, '');

  // cache the listener into the listeners array
  if (!contains(tag.__.listeners, dom)) { tag.__.listeners.push(dom); }
  if (!dom[RIOT_EVENTS_KEY]) { dom[RIOT_EVENTS_KEY] = {}; }
  if (dom[RIOT_EVENTS_KEY][name]) { dom.removeEventListener(eventName, dom[RIOT_EVENTS_KEY][name]); }

  dom[RIOT_EVENTS_KEY][name] = cb;
  dom.addEventListener(eventName, cb, false);
}
670578
def set_event_handler(self, event, handler):
        """"""
        # QUESTION: Should we raise an exception if `event` is not in some
        # known event-type list?

        self._prepare_persistence_engine()

        callbacks = self._options.get('callbacks', {})
        callbacks[event] = handler
        self._options['callbacks'] = callbacks
621279
public function on(string $event, $handler)
    {
        if (self::isSupportedEvent($event)) {
            $this->options[$event] = $handler;
        }
    }
696677
function on(eventNamesOrPatterns, handler) {
    if (!eventNamesOrPatterns) {
      throw new Error('Must pass at least one event name or matching RegEx');
    }
    assert.func(handler, 'handler');
    if (!Array.isArray(eventNamesOrPatterns)) {
      eventNamesOrPatterns = [eventNamesOrPatterns];
    }
    for (let i = 0; i < eventNamesOrPatterns.length; i++) {
      buckets.push({
        pattern: ensureRegExp(eventNamesOrPatterns[i]),
        handler: handler
      });
    }
  }