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

Breadcrumb

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

function Promise::then

Same name in this branch
  1. 11.1.x vendor/php-http/guzzle7-adapter/src/Promise.php \Http\Adapter\Guzzle7\Promise::then()
  2. 11.1.x vendor/php-http/promise/src/Promise.php \Http\Promise\Promise::then()
  3. 11.1.x vendor/guzzlehttp/promises/src/Promise.php \GuzzleHttp\Promise\Promise::then()

Overrides PromiseInterface::then

2 calls to Promise::then()
Promise::catch in vendor/react/promise/src/Promise.php
@template TThrowable of \Throwable @template TRejected
Promise::finally in vendor/react/promise/src/Promise.php
Allows you to execute "cleanup" type tasks in a promise chain.

File

vendor/react/promise/src/Promise.php, line 44

Class

Promise
@template T @template-implements PromiseInterface<T>

Namespace

React\Promise

Code

public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface {
    if (null !== $this->result) {
        return $this->result
            ->then($onFulfilled, $onRejected);
    }
    if (null === $this->canceller) {
        return new static($this->resolver($onFulfilled, $onRejected));
    }
    // This promise has a canceller, so we create a new child promise which
    // has a canceller that invokes the parent canceller if all other
    // followers are also cancelled. We keep a reference to this promise
    // instance for the static canceller function and clear this to avoid
    // keeping a cyclic reference between parent and follower.
    $parent = $this;
    ++$parent->requiredCancelRequests;
    return new static($this->resolver($onFulfilled, $onRejected), static function () use (&$parent) : void {
        assert($parent instanceof self);
        --$parent->requiredCancelRequests;
        if ($parent->requiredCancelRequests <= 0) {
            $parent->cancel();
        }
        $parent = null;
    });
}

API Navigation

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