Execute the given callback in a scoped browser once the selector is available.

@param  string  $selector
@param  Closure  $callback
@param  int  $seconds
@return $this
@throws \Facebook\WebDriver\Exception\TimeOutException
971652
public function whenAvailable($selector, Closure $callback, $seconds = null)
    {
        return $this->waitFor($selector, $seconds)->with($selector, $callback);
    }
37786
public function extend($driver, \Closure $callback)
    {
        $this->customCreators[$driver] = $callback->bindTo($this, $this);

        return $this;
    }
142436
public function then(\Closure $callback)
	{
		$response = $this->layers[0]->handle($this->request);

		return call_user_func($callback, $this->request, $response);
	}
755481
protected function executeCommand($command, $timeout = 300, $callback = null)
    {
        $process = new Process($this->prepare($command), $this->cwd, null, null, $timeout);
        $process->run($callback);
        if (!$process->isSuccessful()) {
            throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', $command));
        }
    }
952977
public function selector($selector)
    {
        if( is_scalar($selector) )
        {
            $this->selector = json_encode($selector);
        }
        else
        {
            $this->selector = Buffering\Callback::do($selector);
        }
        

        return $this;
    }
320544
public function update(string $id, Closure $callback): self
    {
        if (str_contains($id, ',')) {
            collect(explode(',', $id))
                ->map('trim')
                ->each(function ($element) use ($callback) {
                    $this->update($element, $callback);
                });

            return $this;
        }

        $element = $this->find($id);

        if ($element && $callback) {
            $callback($element);
        }

        return $this;
    }
346600
public function setTimeout(float $seconds): self
    {
        $this->validateTimeout($seconds);
        $this->timeout = $seconds;

        return $this;
    }
1353389
public static function getOrSet(string $key, \Closure $functionOnSet, int $seconds = null)
    {
        return static::getAdapter()->getOrSet($key, $functionOnSet, $seconds);
    }
387098
public function waitUntil($script, $seconds = null, $message = null)
    {
        if (! Str::startsWith($script, 'return ')) {
            $script = 'return '.$script;
        }

        if (! Str::endsWith($script, ';')) {
            $script = $script.';';
        }

        return $this->waitUsing($seconds, 100, function () use ($script) {
            return $this->driver->executeScript($script);
        }, $message);
    }
977989
public static function make($cache, \Closure $callback)
    {
        // Return Closure callback
        if (array_key_exists($cache, static::$drivers)) {
            return static::getCacheDriver($callback, $cache);
        }

        throw new \RuntimeException('Cache driver not found!');
    }
301773
function setTimeout($seconds)
    {
        if (is_array($seconds))
            $seconds = implode('.', $seconds);

        $this->timeout = $seconds;
        return $this;
    }
1318025
public function after(\Closure $callback) : ValidatorInterface
    {
        $this->after[] = function () use ($callback) {
            return call_user_func_array($callback, [$this]);
        };

        return $this;
    }
1273639
function (minimumInterval, callback) {
    var timeout = null;
    return function () {
        var that = this, args = arguments;
        if(timeout === null) {
            timeout = setTimeout(function () {
                timeout = null;
            }, minimumInterval);
            callback.apply(that, args);
        }
    };
}
788027
public function push($element, Closure $callback = null): self
    {
        $element = $this->createElement($element);

        if ($callback) {
            $callback($element);
        }

        parent::push($element);

        return $this;
    }
275383
public function waitUntilMissing($selector, $seconds = null)
    {
        $message = $this->formatTimeOutMessage('Waited %s seconds for removal of selector', $selector);

        return $this->waitUsing($seconds, 100, function () use ($selector) {
            try {
                $missing = ! $this->resolver->findOrFail($selector)->isDisplayed();
            } catch (NoSuchElementException $e) {
                $missing = true;
            }

            return $missing;
        }, $message);
    }
580643
public function setCallback($callback)
    {
        if (!$callback instanceof Closure) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Invalid parameter for callback: must be %s',
                Closure::class
            ));
        }

        return parent::setCallback($callback);
    }
961552
public static function run($function=null,$callback=null) {
        $that = self::instance();

        if($function instanceof \Closure) {
            $callback = $function;
            $function = Router::driver()->function;
        }

        $that->on($that->defaultCall,$callback);

        return $that->with($function);
    }