register a event handler
@param          $event
@param callable $handler
@param bool     $once
160865
public function on(string $event, callable $handler, $once = false): void
    {
        if (self::isSupportedEvent($event)) {
            self::$eventHandlers[$event][] = $handler;

            if (!isset(self::$events[$event])) {
                self::$events[$event] = (bool)$once;
            }
        }
    }
109970
final protected function setHandler($handler)
    {
        if (is_callable($handler, false)) {
            $this->handleStack = ['default' => $handler];
        } elseif (is_object($handler)) {
            $this->handler = $handler;
        } else {
            $this->name = $handler;
        }
    }
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
    });
}
832406
function onEventHandledEEArr(event){
  var pd = this[proxied],
      p = this;
  
  function onEvent(){
    p.fire(event,arguments);
  }
  
  p[proxiedHandlers][event] = onEvent;
  pd.on(event,onEvent);
}
108454
def on(self, name, callback, once=False):
        
        if name not in self.event_listeners:
            self.event_listeners[name] = []

        self.event_listeners[name].append((callback, once))
457583
function onEvent(gesture, handler) {
    var gestures = gesture.split(' ');
    Utils.each(gestures, function(gesture) {
      this.element.addEventListener(gesture, handler, false);
      this.eventHandlers.push({ gesture: gesture, handler: handler });
    }, this);
    return this;
  }
753275
def register(self, event, fn):
        

        # TODO: Can we check the method signature?
        self._handler_dict.setdefault(event, [])
        if fn not in self._handler_dict[event]:
            self._handler_dict[event].append(fn)
10759
public static <T extends Event> HandlerRegistration bind(EventTarget target, EventType<T, ?> type,
            EventCallbackFn<T> listener) {
        return bind(target, type.name, e -> listener.onEvent(Js.cast(e)));
    }
1224121
protected function registerSwooleEvents($handler, array $events)
    {
        foreach ($events as $event => $beanName) {
            $object = bean($beanName);
            $method = SwooleEvent::getHandlerFunction($event);
            $handler->on($event, [$object, $method]);
        }
    }
601343
function(implementOn, event, callback, selector, context, once) {
	var self = this,

	stringy = callback.toString(),
	
	wrappedListener = function (e){

		var eventWrapper = new NWTEventInstance(e),

		selfCallee = arguments.callee,

		returnControl = function() {
			// Call the callback
			// Prepend the wrapped event onto the argument list so we can expect what arguments we get
			localnwt.event._eventData.unshift(eventWrapper);
			callback.apply(implementOn, localnwt.event._eventData);
			localnwt.event._eventData = [];

			if (once) {
				implementOn.removeEventListener(event, selfCallee);
			}
		};

		if (selector) {
			implementOn.all(selector).each(function(userEl) {
				if (userEl._node == eventWrapper.target._node) {
					returnControl();
				}
			});
			return;
		}
		returnControl();
	};

	// Push the callback onto the cached string
	self._cached[stringy] = self._cached[stringy] || [];
	self._cached[stringy].push({
		type: event,
		obj: implementOn,
		fn: wrappedListener,
		raw: callback
	})

	return wrappedListener;
}
327513
protected static function registerObservableEvent($event, $callback)
    {
        if (! isset(static::$dispatcher)) {
            return ;
        }

        $className = get_called_class();

        $event = with(new static())->getObservableKey($event);

        static::$dispatcher->listen("{$event}: {$className}", $callback);
    }
1117863
public function registerCallback( $event, $callback ) {

		if ( !is_string( $event ) ) {
			throw new InvalidArgumentException( "Event is not a string" );
		}

		if ( !is_callable( $callback ) ) {
			throw new RuntimeException( "Invoked object is not a valid callback or Closure" );
		}

		$this->addToCollection( $event, new GenericCallbackEventListener( $callback ) );
	}
1037060
public function on(string $name, callable $function, array $functionArguments = null,
        bool $once = true): void
    {
        $name = $this->normalizeName($name);

        $this->stack[$name] = new Event($name, $function, $functionArguments, $once);
    }
1051601
public function listen($event, $handler)
    {
        if(array_key_exists($event, $this->broadcast)) {

            $eventObject = $this->getEventObject($event, $this->broadcast[$event]);

            if(is_callable($handler)) {
                call_user_func_array($handler, [$eventObject]);
            } else {
                call_user_func_array([$this->app->make($handler), 'listen'], [$eventObject]);
            }
        }
    }
1129831
public function setHandler($handler)
    {
        if (Assert::array($handler)) {
            $this->handler = function (Event $event) use ($handler) {
                return call_user_func_array($handler, [$event]);
            };
        } elseif (Assert::instanceOf($handler, '\\Closure')) {
            $this->handler = $handler;
        } else {
            throw new InvalidArgumentException('`Listener::$handler` must be `array` or `Closure`');
        }
    }
65189
public function once($event, $listener, int $priority = Priority::NORMAL)
    {
        $this->addListener($event, $listener, $priority, true);
    }
902398
function once(event, listener) {
  function g() {
    this.removeListener(event, g);
    listener.apply(this, arguments);
  };
  this.on(event, g);
  return this;
}