Future::__construct PHP Метод

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

public __construct ( $computation = NULL )
    public function __construct($computation = NULL)
    {
        if (is_callable($computation)) {
            try {
                $this->resolve(call_user_func($computation));
            } catch (UncatchableException $e) {
                throw $e->getPrevious();
            } catch (Exception $e) {
                $this->reject($e);
            } catch (Throwable $e) {
                $this->reject($e);
            }
        }
    }

Usage Example

Пример #1
0
 public function __construct($executor = null)
 {
     parent::__construct();
     if (is_callable($executor)) {
         $self = $this;
         call_user_func($executor, function ($value) use($self) {
             $self->resolve($value);
         }, function ($reason) use($self) {
             $self->reject($reason);
         });
     }
 }
All Usage Examples Of Future::__construct