Amp\Internal\PrivatePromise::__construct PHP Method

__construct() public method

public __construct ( callable $resolver )
$resolver callable
    public function __construct(callable $resolver)
    {
        /**
         * Resolves the promise with the given promise or value.
         *
         * @param mixed $value
         */
        $resolve = function ($value = null) {
            $this->resolve($value);
        };
        /**
         * Fails the promise with the given exception.
         *
         * @param \Throwable $reason
         */
        $fail = function (\Throwable $reason) {
            $this->fail($reason);
        };
        try {
            $resolver($resolve, $fail);
        } catch (\Throwable $exception) {
            $this->fail($exception);
        }
    }
PrivatePromise