2
namespace GuzzleHttp\Ring\Future;
4
use React\Promise\FulfilledPromise;
5
use React\Promise\RejectedPromise;
8
* Represents a future value that has been resolved or rejected.
10
class CompletedFutureValue implements FutureInterface
15
private $cachedPromise;
18
* @param mixed $result Resolved result
19
* @param \Exception $e Error. Pass a GuzzleHttp\Ring\Exception\CancelledFutureAccessException
20
* to mark the future as cancelled.
22
public function __construct($result, \Exception $e = null)
24
$this->result = $result;
28
public function wait()
37
public function cancel() {}
39
public function promise()
41
if (!$this->cachedPromise) {
42
$this->cachedPromise = $this->error
43
? new RejectedPromise($this->error)
44
: new FulfilledPromise($this->result);
47
return $this->cachedPromise;
51
callable $onFulfilled = null,
52
callable $onRejected = null,
53
callable $onProgress = null
55
return $this->promise()->then($onFulfilled, $onRejected, $onProgress);