Predis\Client::createPubSub PHP Method

createPubSub() protected method

Actual publish/subscribe context initializer method.
protected createPubSub ( array $options = null, mixed $callable = null ) : Consumer | null
$options array Options for the context.
$callable mixed Optional callable used to execute the context.
return Predis\PubSub\Consumer | null
    protected function createPubSub(array $options = null, $callable = null)
    {
        $pubsub = new PubSubConsumer($this, $options);
        if (!isset($callable)) {
            return $pubsub;
        }
        foreach ($pubsub as $message) {
            if (call_user_func($callable, $pubsub, $message) === false) {
                $pubsub->stop();
            }
        }
    }