Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\Adapter

SyncPromise::thenpublicWC 1.0

Method of the class: SyncPromise{}

No Hooks.

Returns

null. Nothing (null).

Usage

$SyncPromise = new SyncPromise();
$SyncPromise->then( ?callable $onFulfilled, ?callable $onRejected ): self;
?callable $onFulfilled
.
Default: null
?callable $onRejected
.
Default: null

SyncPromise::then() code WC 10.9.1

public function then(?callable $onFulfilled = null, ?callable $onRejected = null): self
{
    if ($this->state === self::REJECTED
        && $onRejected === null
    ) {
        return $this;
    }

    if ($this->state === self::FULFILLED
        && $onFulfilled === null
    ) {
        return $this;
    }

    $child = new self();

    $this->waiting[] = [$child, $onFulfilled, $onRejected];

    if ($this->state !== self::PENDING) {
        $this->enqueueWaitingPromises();
    }

    return $child;
}