Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EachPromise.php

function EachPromise::addPending

1 call to EachPromise::addPending()
EachPromise::refillPending in vendor/guzzlehttp/promises/src/EachPromise.php

File

vendor/guzzlehttp/promises/src/EachPromise.php, line 157

Class

EachPromise
Represents a promise that iterates over many promises and invokes side-effect functions in the process.

Namespace

GuzzleHttp\Promise

Code

private function addPending() : bool {
    if (!$this->iterable || !$this->iterable
        ->valid()) {
        return false;
    }
    $promise = Create::promiseFor($this->iterable
        ->current());
    $key = $this->iterable
        ->key();
    // Iterable keys may not be unique, so we use a counter to
    // guarantee uniqueness
    $idx = $this->nextPendingIndex++;
    $this->pending[$idx] = $promise->then(function ($value) use ($idx, $key) : void {
        if ($this->onFulfilled) {
            ($this->onFulfilled)($value, $key, $this->aggregate);
        }
        $this->step($idx);
    }, function ($reason) use ($idx, $key) : void {
        if ($this->onRejected) {
            ($this->onRejected)($reason, $key, $this->aggregate);
        }
        $this->step($idx);
    });
    return true;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal