Ejemplo n.º 1
0
 /**
  * @test
  */
 public function from_promise_success()
 {
     $source = PromiseFactory::toObservable(function () {
         return Promise::resolved(42);
     });
     $results = $this->scheduler->startWithCreate(function () use($source) {
         return $source;
     });
     $this->assertMessages(array(onNext(200, 42), onCompleted(200)), $results->getMessages());
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function from_promise_reject()
 {
     $error = new Exception("Test exception");
     $source = PromiseFactory::toObservable(function () use($error) {
         return Promise::rejected($error);
     });
     $theException = null;
     $source->subscribeCallback([$this, 'fail'], function ($err) use(&$theException) {
         $theException = $err;
     }, [$this, 'fail'], $this->scheduler);
     $this->scheduler->start();
     $this->assertTrue($theException instanceof Exception);
     $this->assertSame($error, $theException);
 }
Ejemplo n.º 3
0
<?php

require_once __DIR__ . '/../bootstrap.php';
/* Using a promise */
$source = \Rx\React\PromiseFactory::toObservable(function () {
    return \Rx\React\Promise::resolved(42);
});
$subscription = $source->subscribe($createStdoutObserver());
//Next value: 42
//Complete!