React\Promise\Promise::done PHP Метод

done() публичный Метод

public done ( callable $onFulfilled = null, callable $onRejected = null )
$onFulfilled callable
$onRejected callable
    public function done(callable $onFulfilled = null, callable $onRejected = null)
    {
        if (null !== $this->result) {
            return $this->result()->done($onFulfilled, $onRejected);
        }
        $this->handlers[] = function (ExtendedPromiseInterface $promise) use($onFulfilled, $onRejected) {
            $promise->done($onFulfilled, $onRejected);
        };
    }

Usage Example

Пример #1
0
 public function fromPromise(Promise $promise)
 {
     $json = null;
     $promise->done(function ($data) use(&$json) {
         $json = $data;
     });
     return new \Zend\Diactoros\Response\JsonResponse($json);
 }