SyncPromiseAdapter
in package
implements
PromiseAdapter
Allows changing order of field resolution even in sync environments (by leveraging queue of deferreds and promises).
Interfaces, Classes and Traits
- PromiseAdapter
- Provides a means for integration of async PHP platforms ([related docs](data-fetching.md#async-php)).
Table of Contents
- all() : Promise
- Given an iterable of promises (or values), returns a promise that is fulfilled when all the items in the iterable are fulfilled.
- convertThenable() : Promise
- Converts thenable of the underlying platform into Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\Promise instance.
- create() : Promise
- Creates a Promise from the given resolver callable.
- createFulfilled() : Promise
- Creates a fulfilled Promise for a value if the value is not a promise.
- createRejected() : Promise
- Creates a rejected promise for a reason if the reason is not a promise.
- isThenable() : bool
- Is the value a promise or a deferred of the underlying platform?
- then() : Promise
- Accepts our Promise wrapper, extracts adopted promise out of it and executes actual `then` logic described in Promises/A+ specs. Then returns new wrapped instance of Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\Promise.
- wait() : mixed
- Synchronously wait when promise completes.
- beforeWait() : void
- Execute just before starting to run promise completion.
- onWait() : void
- Execute while running promise completion.
Methods
all()
Given an iterable of promises (or values), returns a promise that is fulfilled when all the items in the iterable are fulfilled.
public
all(iteratable<string|int, mixed> $promisesOrValues) : Promise
Parameters
- $promisesOrValues : iteratable<string|int, mixed>
Tags
Return values
Promise —convertThenable()
Converts thenable of the underlying platform into Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\Promise instance.
public
convertThenable(mixed $thenable) : Promise
Parameters
- $thenable : mixed
Tags
Return values
Promise —create()
Creates a Promise from the given resolver callable.
public
create(callable $resolver) : Promise
Parameters
- $resolver : callable
Tags
Return values
Promise —createFulfilled()
Creates a fulfilled Promise for a value if the value is not a promise.
public
createFulfilled([mixed $value = null ]) : Promise
Parameters
- $value : mixed = null
Tags
Return values
Promise —createRejected()
Creates a rejected promise for a reason if the reason is not a promise.
public
createRejected(Throwable $reason) : Promise
Parameters
- $reason : Throwable
Tags
Return values
Promise —isThenable()
Is the value a promise or a deferred of the underlying platform?
public
isThenable(mixed $value) : bool
Parameters
- $value : mixed
Return values
bool —then()
Accepts our Promise wrapper, extracts adopted promise out of it and executes actual `then` logic described in Promises/A+ specs. Then returns new wrapped instance of Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\Promise.
public
then(Promise $promise[, callable|null $onFulfilled = null ][, callable|null $onRejected = null ]) : Promise
Parameters
- $promise : Promise
- $onFulfilled : callable|null = null
- $onRejected : callable|null = null
Tags
Return values
Promise —wait()
Synchronously wait when promise completes.
public
wait(Promise $promise) : mixed
Parameters
- $promise : Promise
Tags
Return values
mixed —beforeWait()
Execute just before starting to run promise completion.
protected
beforeWait(Promise $promise) : void
Parameters
- $promise : Promise
Return values
void —onWait()
Execute while running promise completion.
protected
onWait(Promise $promise) : void
Parameters
- $promise : Promise
