Future::__construct PHP Method

__construct() public method

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
ファイル: Promise.php プロジェクト: wanggeopens/own-libs
 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