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

Breadcrumb

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

function PromiseInterface::then

Same name in this branch
  1. 11.1.x vendor/guzzlehttp/promises/src/PromiseInterface.php \GuzzleHttp\Promise\PromiseInterface::then()

Transforms a promise's value by applying a function to the promise's fulfillment or rejection value. Returns a new promise for the transformed result.

The `then()` method registers new fulfilled and rejection handlers with a promise (all parameters are optional):

  • `$onFulfilled` will be invoked once the promise is fulfilled and passed the result as the first argument.
  • `$onRejected` will be invoked once the promise is rejected and passed the reason as the first argument.

It returns a new promise that will fulfill with the return value of either `$onFulfilled` or `$onRejected`, whichever is called, or will reject with the thrown exception if either throws.

A promise makes the following guarantees about handlers registered in the same call to `then()`:

1. Only one of `$onFulfilled` or `$onRejected` will be called, never both. 2. `$onFulfilled` and `$onRejected` will never be called more than once.

@template TFulfilled @template TRejected

Parameters

?(callable((T is void ? null : T)): (PromiseInterface<TFulfilled>|TFulfilled)) $onFulfilled:

?(callable(\Throwable): (PromiseInterface<TRejected>|TRejected)) $onRejected:

Return value

PromiseInterface<($onRejected is null ? ($onFulfilled is null ? T : TFulfilled) : ($onFulfilled is null ? T|TRejected : TFulfilled|TRejected))>

3 methods override PromiseInterface::then()
FulfilledPromise::then in vendor/react/promise/src/Internal/FulfilledPromise.php
@template TFulfilled
Promise::then in vendor/react/promise/src/Promise.php
Transforms a promise's value by applying a function to the promise's fulfillment or rejection value. Returns a new promise for the transformed result.
RejectedPromise::then in vendor/react/promise/src/Internal/RejectedPromise.php
@template TRejected

File

vendor/react/promise/src/PromiseInterface.php, line 40

Class

PromiseInterface
@template-covariant T

Namespace

React\Promise

Code

public function then(?callable $onFulfilled = null, ?callable $onRejected = null) : PromiseInterface;

API Navigation

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