Adds new listener.

@param  string    $topic
@param  callable  $callback

@return void
766828
public function on(string $topic, callable $callback) : void
    {
        if (is_null($this->zeromq)) {
            throw new BadMethodCallException(
                'ZeroMQ support is not available, because '.
                '"denpa/laravel-zeromq" package is not installed. '.
                'Please install it.'
            );
        }

        $this->zeromq->add(new ZeroMQ\Listener($topic, $callback));
    }
241399
function addListener(event, callback, meta) {
  event.listeners.push(callback);
  event.meta.set(callback, meta);
}
613378
public function set_return_listener($callback)
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException(sprintf(
                'Given callback "%s" should be callable. %s type was given.',
                $callback,
                gettype($callback)
            ));
        }

        $this->basic_return_callback = $callback;
    }
186925
public function listen($event, \Closure $callback): void
    {
        // check if $event is a single string and set it as array with one item
        if (!Any::isArray($event)) {
            $event = [$event];
        }
        
        // each every one event in array
        foreach ($event as $item) {
            if (Any::isArray($this->runned) && array_key_exists($item, $this->runned)) {
                call_user_func_array($callback, $this->runned[$item]);
            }
        }
    }
435067
public function registerCallback($event, $callback)
    {
        $this->checkEventType($event);
        $this->events[$event][] = $callback;
    }
274879
public function onLogQuery(callable $callback = null)
    {
        if ($callback === null || is_callable($callback)) {
            $this->on_log_query = $callback;
        } else {
            throw new InvalidArgumentException('Callback needs to be NULL or callable');
        }
    }
926651
public function attach($eventName, $callback, $priority = 1): void
    {
        if (!isset($this->listeners[$eventName])) {
            $this->listeners[$eventName] = [];
        }
        if (!isset($this->listeners[$eventName][$priority])) {
            $this->listeners[$eventName][$priority] = [];
        }
        $this->listeners[$eventName][$priority][] = $callback;
    }
379471
public function attach(string $event, callable $callback, int $priority = self::PRIORITY_MIN): void
    {

        /* If there aren't any listeners for an event yet */
        if (empty($this->events[$event])) {

            /* Create a new queue for the event. */
            $this->events[$event] = new PriorityQueue();
        }

        /* Create a new listener with the given data */
        $listener = new EventListener($event, $callback, $priority);

        /* Insert the new callback into the queue. */
        $this->events[$event]->insert($listener, $priority);
    }
1310029
def _setup_notification_listener(self, topic_name, url):
        """"""

        self.notify_listener = rpc.DfaNotifcationListener(
            topic_name, url, rpc.DfaNotificationEndpoints(self))
500103
public function listen($eventNames, callable $callback)
    {
        if (!is_array($eventNames)) {
            $eventNames = [$eventNames];
        }

        foreach ($eventNames as $eventName) {
            $this->attachListener($eventName, $callback);
        }
    }
1350188
public function addEventListener(callable $listener): void
    {
        /** @var \Jasny\EventDispatcher\EventDispatcher $dispatcher */
        $dispatcher = type_check(
            $this->getEventDispatcher(),
            'Jasny\EventDispatcher\EventDispatcher',
            new LogicException('Unsupported event dispatcher. Please overload the addEventListener method.')
        );

        /** @var \Jasny\EventDispatcher\ListenerProvider $provider */
        $provider = type_check(
            $dispatcher->getListenerProvider(),
            'Jasny\EventDispatcher\ListenerProvider',
            new UnexpectedValueException('Unsupported listener provider; expected %2s, got %1s')
        );

        $newProvider = $provider->withListener($listener);
        $newDispatcher = $dispatcher->withListenerProvider($newProvider);

        $this->setEventDispatcher($newDispatcher);
    }
1097579
public function set_nack_handler($callback)
    {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException(sprintf(
                'Given callback "%s" should be callable. %s type was given.',
                $callback,
                gettype($callback)
            ));
        }

        $this->nack_handler = $callback;
    }
397742
public function listen($events, $listener, $priority=0)
    {

        if (!is_callable($listener)) {
            throw new InvalidArgumentException('Listener has to be callable');
        }

        foreach ((array)$events as $event) {

            if ($this->isWildcardSyntax($event)){
                $this->addWildCardListener($event, $listener, $priority);
            }
            $this->addListener($event, $listener, $priority);

        }
    }
811342
public function addCallback($name, $callback, $prio = 10)
    {
        if (!is_callable($callback)) {
            throw new \Exception("Callback not callable.", 3);
            return false;
        }
        $key = $this->getCallbackKey($callback);
        if (!isset(self::$_baseRealCallbacks[$key])) {
            self::$_baseRealCallbacks[$key] = $callback;
        }

        $this->_callbacks[$name][$prio][] = $key;
        ksort($this->_callbacks[$name]);

        return $this;
    }
373101
public static function Listen($signal_type, $callback, $priority = 10)
    {
        if(!isset(self::$listeners[$signal_type]))
            self::$listeners[$signal_type] = array();

        self::$listeners[$signal_type][] = array(
            'callback' => $callback,
            'priority' => $priority
        );

        self::$listeners[$signal_type] = self::Sort(
            self::$listeners[$signal_type], 'priority'
        );
    }
804147
public static function listen(string $event, callable $callback) {
		if (!isset(self::$events[$event])) {
			self::$events[$event] = [];
		}
		self::$events[$event][] = $callback;
	}
876532
public static function listen($event, $callback)
    {
        if (is_array($event)) {
            foreach ($event as $e) {
                self::listen($e, $callback);
            }
            return;
        }

        if ($event !== '*' and !self::eventName($event)) {
            throw new \InvalidArgumentException('Event "'.$event.'" is not a valid event');
        }

        if (!isset(self::$events[$event])) {
            self::$events[$event] = array();
        }

        self::$events[$event][] = $callback;
    }