Generic wrap for Event system subscription.
@see \samson\core\\samsonphp\event\Event::subscribe()

@param string   $key     Event identifier
@param callable $handler Event handler
@param array    $params  Event parameters

@return $this Chaining
506736
public function subscribe($key, $handler, $params = array())
    {
        Event::subscribe($key, $handler, $params);

        return $this;
    }
571502
public function register($name, $handler)
    {
        if (is_callable($handler)) {
            $params = array_merge(array($this), $this->params);
            $this->container[$name] = call_user_func_array($handler, $params);

        } else {
            $this->container[$name] = $handler;
        }

        return $this;
    }
1321922
public function attachHandler(callable $handler, $key = null)
    {
        if ($key !== null) {
            $this->eventHandlers[$key] = $handler;
        } else {
            $this->eventHandlers[] = $handler;
        }
    }
957173
public function updateSubscription($params = null)
    {
        $url = $this->instanceUrl() . '/subscription';
        list($response, $opts) = $this->_request('post', $url, $params);
        $this->refreshFrom(['subscription' => $response], $opts, true);
        return $this->subscription;
    }
498900
public function subscribe($eventName, $callable, $priority = 0)
    {
        if (!is_callable($callable)) {
            throw new SubscriberNotCallable();
        }

        $this->eventList[$eventName][$priority][] = $callable;

        /*
         * Clear cached sorted array
         */
        unset($this->sorted[$eventName]);

        return $this;
    }
1279155
public function runController($handler, array $params = [])
    {
        return SystemHelpers::call(
                $this->prepareCallback($handler),
                function($paramName) use ($params) {
                if (($component = $this->getComponent($paramName)) !== null) {
                    return $component;
                }
                if (isset($_GET[$paramName])) {
                    return $_GET[$paramName];
                }
                if (isset($_POST[$paramName])) {
                    return $_POST[$paramName];
                }
                if (isset($params[$paramName])) {
                    return $params[$paramName];
                }
            });
    }
320667
public function handleSubscribeCallback($message, $expr, callable $handler)
    {
        $event = $this->translator->translate($message);
        if ($event) {
            // we were able to translate the message into an event
            if ($event->matches($expr)) {
                // the event matches the listen expression
                call_user_func($handler, $event);
            } else {
                // pass to listen expr fail handler?
                if ($this->listenExprFailHandler) {
                    call_user_func($this->listenExprFailHandler, $event, $expr);
                }
            }
        } else {
            // pass to translate fail handler?
            if ($this->translateFailHandler) {
                call_user_func($this->translateFailHandler, $message);
            }
        }
    }
341721
public int subscribe(final String subscriptionName, Object[] params) {
        // add the subscription to the HashMap with its initial value "false" which says that it is not ready
        subscriptionsAreReady.put(subscriptionName, false);
        
        // subscribe to a Meteor collection with given params
        // test error handling for invalid subscription
        return getDDP().subscribe(subscriptionName, params, new DDPListener() {
            @Override
            public void onReady(String id) {
                // mark subscription ready
                subscriptionsAreReady.replace(subscriptionName, true);

                // broadcast that subscription has been updated
                broadcastSubscriptionChanged(subscriptionName,
                        DdpMessageType.READY, null);
            }

            @Override
            public void onResult(Map<String, Object> jsonFields) {
                String msgtype = (String) jsonFields
                        .get(DdpMessageField.MSG);
                // ignore {"server_id":"GqrKrbcSeDfTYDkzQ"} web socket msgs
                if ((msgtype != null) && (msgtype.equals(DdpMessageType.ERROR))) {
                    broadcastDDPError((String) jsonFields
                            .get(DdpMessageField.ERRORMSG));
                }
            }
        });
    }
849515
public function call($service, ...$params)
    {
        if (! $this->hasHandler($service)) {
            throw ServiceHandlerMethodException::notFound($service);
        }

        return $this->container->make($service)->{$this::$handlerMethod}(...$params);
    }
134664
public function subscribe($requestParams)
    {
        $requiredParams = array("event","url");
        return $this->client->request($requestParams, $this->_endpoint . "/" . self::SUBSCRIBE, "post", $requiredParams, $options = NULL);
    }
332683
public static function relative($handler, array $params = [])
    {
        return substr(app()->request->base_url, 0, -1).app()->router->generate($handler, $params);
    }
761575
public function subscribe(string $event, string $listener, callable $callback)
    {
        $callbackKey = $event . ' ' . $listener;
        $this->events[$event][] = $callbackKey;
        $this->subscriptions[$callbackKey] = $callback;
    }
366430
def subscribe(self, handler):
        """"""
        assert callable(handler), "Invalid handler %s" % handler
        self.handlers.append(handler)
835129
public function onSubscribe(\Closure $handler)
    {
        $this->managers[] = new Manager(function (Event $event) {
            return ($event instanceof \Viber\Api\Event\Subscribed);
        }, $handler);

        return $this;
    }
1360163
public function setHandler($handler)
    {
        $handler = new $handler($this->config);

        if (!$handler instanceof HandlerInterface) {
            throw new \RuntimeException('Handler not initialized. Please use Handler class instanceof HandlerInterface.');
        }

        $this->handler = $handler;

        return $this;
    }
880843
def subscribe_parameter(param, &callback)
      sub = ParameterSubscriber.new(param, callback)
      @manager.add_parameter_subscriber(sub)
      sub
    end
786112
public function listenToQueue(array $handlers , $routingKey = null, $options =[] )
    {
        /* Look for handlers */
        $handlersMap = array();
        foreach ($handlers as $handlerClassPath) {
            if (!class_exists($handlerClassPath)) {
                $handlerClassPath = "Kontoulis\\RabbitMQLaravel\\Handlers\\DefaultHandler";
                if (!class_exists($handlerClassPath)) {
                    throw new BrokerException(
                        "Class $handlerClassPath was not found!"
                    );
                }
            }
            $handlerOb = new $handlerClassPath();
            $classPathParts = explode("\\", $handlerClassPath);
            $handlersMap[$classPathParts[count($classPathParts) - 1]] = $handlerOb;
        }

        $this->queueDeclareBind($routingKey);
        /* Start consuming */
        $this->basic_qos(
            (isset($options["prefetch_size"]) ? $options["prefetch_size"] : null),
            (isset($options["prefetch_count"]) ? $options["prefetch_count"] : 1),
            (isset($options["a_global"]) ? $options["a_global"] : null)
        );
        $this->basic_consume(
            $routingKey,
            (isset($options["consumer_tag"]) ? $options["consumer_tag"] : ''),
            (isset($options["no_local"]) ? (bool)$options["no_local"] : false),
            (isset($options["no_ack"]) ? (bool)$options["no_ack"] : false),
            (isset($options["exclusive"]) ? (bool)$options["exclusive"] : false),
            (isset($options["no_wait"]) ? (bool)$options["no_wait"] : false),
            function (AMQPMessage $amqpMsg) use($handlersMap) {
                $msg = Message::fromAMQPMessage($amqpMsg);
                $this->handleMessage($msg, $handlersMap);
            }
        );
        return $this->waitConsume($options);
    }