Rx\Functional\Operator\TakeWhileTest::takeWhile_throw PHP Method

takeWhile_throw() public method

public takeWhile_throw ( )
    public function takeWhile_throw()
    {
        $error = new \Exception();
        $xs = $this->createHotObservable([onNext(90, -1), onNext(110, -1), onNext(210, 2), onNext(260, 5), onNext(290, 13), onNext(320, 3), onNext(350, 7), onNext(390, 4), onNext(410, 17), onNext(450, 8), onNext(500, 23), onCompleted(600)]);
        $invoked = 0;
        $results = $this->scheduler->startWithCreate(function () use($xs, &$invoked, $error) {
            return $xs->takeWhile(function ($x) use(&$invoked, $error) {
                $invoked++;
                if ($invoked === 3) {
                    throw $error;
                }
                return $this->isPrime($x);
            });
        });
        $this->assertMessages([onNext(210, 2), onNext(260, 5), onError(290, $error)], $results->getMessages());
        $this->assertSubscriptions([subscribe(200, 290)], $xs->getSubscriptions());
        $this->assertEquals(3, $invoked);
    }