Amp\Observer::next PHP Méthode

next() public méthode

Succeeds with true if an emitted value is available by calling getCurrent() or false if the observable has resolved. If the observable fails, the returned promise will fail with the same exception.
public next ( ) : Interop\Async\Promise
Résultat Interop\Async\Promise
    public function next() : Promise
    {
        if (isset($this->deferreds[$this->position])) {
            $future = $this->deferreds[$this->position];
            unset($this->values[$this->position], $this->deferreds[$this->position]);
            $future->resolve();
        }
        ++$this->position;
        if (\array_key_exists($this->position, $this->values)) {
            return new Success(true);
        }
        if ($this->resolved) {
            --$this->position;
            if ($this->exception) {
                return new Failure($this->exception);
            }
            return new Success(false);
        }
        $this->deferred = new Deferred();
        return $this->deferred->promise();
    }