public function FulfilledPromise::then in Auth0 Single Sign On 8.2
Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.
Parameters
callable $onFulfilled Invoked when the promise fulfills.:
callable $onRejected Invoked when the promise is rejected.:
Return value
Overrides PromiseInterface::then
1 call to FulfilledPromise::then()
- FulfilledPromise::otherwise in vendor/
guzzlehttp/ promises/ src/ FulfilledPromise.php - Appends a rejection handler callback to the promise, and returns a new promise resolving to the return value of the callback if it is called, or to its original fulfillment value if the promise is instead fulfilled.
File
- vendor/
guzzlehttp/ promises/ src/ FulfilledPromise.php, line 24
Class
- FulfilledPromise
- A promise that has been fulfilled.
Namespace
GuzzleHttp\PromiseCode
public function then(callable $onFulfilled = null, callable $onRejected = null) {
// Return itself if there is no onFulfilled function.
if (!$onFulfilled) {
return $this;
}
$queue = queue();
$p = new Promise([
$queue,
'run',
]);
$value = $this->value;
$queue
->add(static function () use ($p, $value, $onFulfilled) {
if ($p
->getState() === self::PENDING) {
try {
$p
->resolve($onFulfilled($value));
} catch (\Throwable $e) {
$p
->reject($e);
} catch (\Exception $e) {
$p
->reject($e);
}
}
});
return $p;
}