Subscribe a handler to a channel.

@param string $channel
@param callable $handler
554874
public function subscribe($channel, callable $handler)
    {
        if (!isset($this->subscribers[$channel])) {
            $this->subscribers[$channel] = [];
        }
        $this->subscribers[$channel][] = $handler;
    }
698405
public function psubscribe( $channels, Closure $callback, $connection = null )
	{
		$this->subscribe( $channels, $callback, $connection, __FUNCTION__ );
	}
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]);
            }
        }
    }
621279
public function on(string $event, $handler)
    {
        if (self::isSupportedEvent($event)) {
            $this->options[$event] = $handler;
        }
    }
127825
public function subscribe($subscriber)
    {
        list($className, $method) = Str::parseCallback($subscriber, 'subscribe');

        $instance = $this->container->make($className);

        call_user_func_array([$instance, $method], [$this]);
    }
858816
public function instantiate(string $handler) : EventHandler
    {
        if (false === isset($this->handlers[$handler])) {
            throw new InvalidArgumentException(
                sprintf('Handler %s could not be found. Did you register it?', $handler)
            );
        }

        $callable = $this->handlers[$handler];

        return ($callable instanceof \Closure) ? $callable() : new $callable();
    }
1190439
public function handler($handler)
    {

        if ($this->isNumber($handler) || $this->isBoolean($handler) || $this->isEmpty($handler)) {
            throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
        }

        if ($this->isString($handler) || $this->isStringObject($handler)) {
            $handler = StdObjectWrapper::toString($handler);
            if (!class_exists($handler)) {
                throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
            }
            $handler = new $handler;
        }
        $this->handler = $handler;

        return $this;
    }
884930
def auto_subscribe(self, app_manager):
        """"""
        for handler in app_manager.handler_classes:
            app_manager.subscribe(handler.channel(), self)
228593
public function set_handler(handler $handler) {
        // Make sure there are no conflicts.
        if ($this->get('component') !== $handler->get_component()) {
            throw new \coding_exception('Component of the handler does not match the one from the record');
        }
        if ($this->get('area') !== $handler->get_area()) {
            throw new \coding_exception('Area of the handler does not match the one from the record');
        }
        if ($this->get('itemid') != $handler->get_itemid()) {
            throw new \coding_exception('Itemid of the handler does not match the one from the record');
        }
        if ($this->get('contextid') != $handler->get_configuration_context()->id) {
            throw new \coding_exception('Context of the handler does not match the one from the record');
        }
        $this->handler = $handler;
    }
264920
public void addSubscriber(Handler handler) {
        String handlerId = CollectorManagerUtils.getHandlerId(handler);

        //temporary exception for audit Source  //must change later
        if (source.getSourceName().trim().equals("audit") && subscribers.isEmpty()) {
            //First subscriber, assign a buffer.
            bufferMgr = new BufferManagerImpl(BUFFER_SIZE, sourceId, false);
            //Inform the source that a buffer is now available
            //and it can start sending events to this buffer.
            source.setBufferManager(this.bufferMgr);
        }
        subscribers.add(handlerId);
        /*
         * Inform the handler that this source/buffer/conduit is now available:
         * Synchronous Handler - Add handler as synchronous handler to the Buffer/Conduit's sync handler set
         * Asynchronous Handler - Add handler as asynchronous handler into the Buffer/Conduit
         *
         */
        if (handler instanceof SynchronousHandler) {
            bufferMgr.addSyncHandler((SynchronousHandler) handler);
        } else {
            bufferMgr.addHandler(handlerId);
        }

    }
108448
public function setHandler(callable $handler = null)
    {
        $old = $this->handler;
        $this->handler = $handler;

        return $old;
    }
332188
public function setHandler($handler, $handlerMethod = null) : void
    {
        if (!is_callable($handler) && is_null($handlerMethod)) {
            throw new \InvalidArgumentException(
                'In case the $handler is not a callable, $handlerMethod must specify a method to be called'
            );
        }
        $this->handler = $handler;
        $this->handlerMethod = $handlerMethod;
    }
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;
            }
        }
    }
1082955
public function setRequestHandler($handler)
    {
        $this->requestHandler = $handler;

        $this->requestHandler->setUri($this->url)
            ->setMethod($this->method);

        $this->requestHandler->getUri()->setPort($this->port);

        return $this;
    }
1154311
def on(self, handler):
        """"""
        if not hasattr(handler, '__call__'):
            raise TypeError('handler is not a callable object.')
        self.handlers.add(handler)
38023
static function set_error_logger( $handler ){
		if( ! is_callable($handler) ){
			trigger_error( 'Error logging handler is not callable ('.var_export($handler,1).')', E_USER_WARNING );
			return false;
		}
		PLUGError::$logfunc = $handler;
		return true;
	}
528682
public function subscribe(string $channel): Promise {
        return call(function () use ($channel) {
            yield $this->connection->send(["subscribe", $channel]);

            $emitter = new Emitter;
            $this->emitters[$channel][\spl_object_hash($emitter)] = $emitter;

            return new Subscription($emitter->iterate(), function () use ($emitter, $channel) {
                $this->unloadEmitter($emitter, $channel);
            });
        });
    }