race() public static method

Propagates the observable sequence that reacts first. Also known as 'amb'.
public static race ( array $observables ) : Rx\Observable\AnonymousObservable
$observables array
return Rx\Observable\AnonymousObservable
コード例 #1
0
ファイル: RaceTest.php プロジェクト: ReactiveX/RxPHP
 /**
  * @test
  */
 public function race_throws_before_election()
 {
     $sourceNotDisposed = false;
     $error = new \Exception('error');
     $o1 = $this->createHotObservable([onNext(150, 1), onError(210, $error)]);
     $o2 = $this->createHotObservable([onNext(150, 1), onNext(220, 3), onCompleted(250)])->doOnNext(function () use(&$sourceNotDisposed) {
         $sourceNotDisposed = true;
     });
     $results = $this->scheduler->startWithCreate(function () use($o1, $o2) {
         return Observable::race([$o1, $o2]);
     });
     $this->assertMessages([onError(210, $error)], $results->getMessages());
     $this->assertFalse($sourceNotDisposed);
 }