Rx\React\Promise::rejected PHP Method

rejected() public static method

public static rejected ( mixed $exception ) : Promise
$exception mixed
return React\Promise\Promise A promise rejected with $exception
    public static function rejected($exception)
    {
        $d = new Deferred();
        $d->reject($exception);
        return $d->promise();
    }

Usage Example

Example #1
0
 /**
  * @test
  *
  */
 public function from_promise_failure()
 {
     $p = Promise::rejected(new Exception('error'));
     $source = Promise::toObservable($p);
     $source->subscribe(new CallbackObserver(function ($x) {
         $this->assertFalse(true);
     }, function ($error) {
         $this->assertEquals($error, new Exception('error'));
     }, function () {
         $this->assertFalse(true);
     }));
 }
All Usage Examples Of Rx\React\Promise::rejected