promisor = $promisor; } /** * {@inheritdoc} */ public function onResolve(callable $onResolved) { if ($this->promise === null) { $provider = $this->promisor; $this->promisor = null; try { $this->promise = $provider(); if ($this->promise instanceof \Generator) { $this->promise = new Coroutine($this->promise); } elseif ($this->promise instanceof ReactPromise) { $this->promise = Promise\adapt($this->promise); } elseif (!$this->promise instanceof Promise) { $this->promise = new Success($this->promise); } } catch (\Throwable $exception) { $this->promise = new Failure($exception); } } $this->promise->onResolve($onResolved); } }