Amp\Internal\Placeholder::when PHP 메소드

when() 공개 메소드

또한 보기: Interop\Async\Promise::when()
public when ( callable $onResolved )
$onResolved callable
    public function when(callable $onResolved)
    {
        if ($this->resolved) {
            if ($this->result instanceof Promise) {
                $this->result->when($onResolved);
                return;
            }
            try {
                $onResolved(null, $this->result);
            } catch (\Throwable $exception) {
                Loop::defer(static function () use($exception) {
                    throw $exception;
                });
            }
            return;
        }
        if (null === $this->onResolved) {
            $this->onResolved = $onResolved;
            return;
        }
        if (!$this->onResolved instanceof WhenQueue) {
            $this->onResolved = new WhenQueue($this->onResolved);
        }
        $this->onResolved->push($onResolved);
    }