Automattic\WooCommerce\Vendor\GraphQL
Deferred::__construct
Create a new Deferred promise and enqueue its execution.
Method of the class: Deferred{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Deferred = new Deferred(); $Deferred->__construct( $executor );
- $executor(Executor) (required)
- .
Deferred::__construct() Deferred:: construct code WC 10.9.4
public function __construct(callable $executor)
{
$this->executor = $executor;
SyncPromiseQueue::enqueue(function (): void {
$executor = $this->executor;
assert($executor !== null, 'Always set in constructor, this callback runs only once.');
$this->executor = null;
try {
$this->resolve($executor());
} catch (\Throwable $e) {
$this->reject($e);
}
});
}