File "Deferred.php"
Full Path: /home/fundopuh/trader.fxex.org/vendor/react/promise/src/Deferred.php
File size: 913 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
namespace React\Promise;
/**
* @template T
*/
final class Deferred
{
/**
* @var PromiseInterface<T>
*/
private $promise;
/** @var callable */
private $resolveCallback;
/** @var callable */
private $rejectCallback;
public function __construct(callable $canceller = null)
{
$this->promise = new Promise(function ($resolve, $reject): void {
$this->resolveCallback = $resolve;
$this->rejectCallback = $reject;
}, $canceller);
}
/**
* @return PromiseInterface<T>
*/
public function promise(): PromiseInterface
{
return $this->promise;
}
/**
* @param T $value
*/
public function resolve($value): void
{
($this->resolveCallback)($value);
}
public function reject(\Throwable $reason): void
{
($this->rejectCallback)($reason);
}
}