Rx\Observable::takeWhileWithIndex PHP Method

takeWhileWithIndex() public method

Returns elements from an observable sequence as long as a specified condition is true. It takes as a parameter a a callback to test each source element for a condition. The callback predicate is called with the index and the value of the element.
public takeWhileWithIndex ( callable $predicate ) : Rx\Observable\AnonymousObservable
$predicate callable
return Rx\Observable\AnonymousObservable
    public function takeWhileWithIndex(callable $predicate)
    {
        $index = 0;
        return $this->takeWhile(function ($value) use($predicate, &$index) {
            return call_user_func_array($predicate, [$index++, $value]);
        });
    }