Kafka\ZooKeeper::watch PHP Method

watch() public method

Wath a given path
public watch ( string $path, callable $callback ) : string | null
$path string the path to node
$callback callable callback function
return string | null
    public function watch($path, $callback)
    {
        if (!is_callable($callback)) {
            return null;
        }
        if ($this->zookeeper->exists($path)) {
            if (!isset($this->callback[$path])) {
                $this->callback[$path] = array();
            }
            if (!in_array($callback, $this->callback[$path])) {
                $this->callback[$path][] = $callback;
                return $this->zookeeper->getChildren($path, array($this, 'watchCallback'));
            }
        }
    }