Amp\Internal\LazyPromise::when PHP Method

when() public method

public when ( callable $onResolved )
$onResolved callable
    public function when(callable $onResolved)
    {
        if (null === $this->promise) {
            $provider = $this->provider;
            $this->provider = null;
            try {
                $this->promise = $provider();
                if (!$this->promise instanceof Promise) {
                    $this->promise = new Success($this->promise);
                }
            } catch (\Throwable $exception) {
                $this->promise = new Failure($exception);
            }
        }
        $this->promise->when($onResolved);
    }