mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Fix inline promise creation
This commit is contained in:
parent
383edd1fe1
commit
ab44874626
1 changed files with 13 additions and 13 deletions
|
|
@ -21,6 +21,7 @@ class CoroutinePromiseAdapter implements PromiseAdapter
|
|||
if (!$thenable instanceof CoroutinePromise) {
|
||||
throw new InvariantViolation('Expected instance of SwoolePromise, got ' . Utils::printSafe($thenable));
|
||||
}
|
||||
|
||||
return new Promise($thenable, $this);
|
||||
}
|
||||
|
||||
|
|
@ -34,30 +35,29 @@ class CoroutinePromiseAdapter implements PromiseAdapter
|
|||
|
||||
public function create(callable $resolver): Promise
|
||||
{
|
||||
$promise = new CoroutinePromise();
|
||||
try {
|
||||
$resolver(
|
||||
[$promise, 'resolve'],
|
||||
[$promise, 'reject'],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$promise->reject($e);
|
||||
}
|
||||
$promise = new CoroutinePromise(function($resolve, $reject) use($resolver) {
|
||||
$resolver($resolve, $reject);
|
||||
});
|
||||
|
||||
return new Promise($promise, $this);
|
||||
}
|
||||
|
||||
public function createFulfilled($value = null): Promise
|
||||
{
|
||||
$promise = new CoroutinePromise();
|
||||
$promise = new CoroutinePromise(function($resolve, $reject) use($value) {
|
||||
$resolve($value);
|
||||
});
|
||||
|
||||
return new Promise($promise->resolve($value), $this);
|
||||
return new Promise($promise, $this);
|
||||
}
|
||||
|
||||
public function createRejected($reason): Promise
|
||||
{
|
||||
$promise = new CoroutinePromise();
|
||||
$promise = new CoroutinePromise(function ($resolve, $reject) use ($reason) {
|
||||
$reject($reason);
|
||||
});
|
||||
|
||||
return new Promise($promise->reject($reason), $this);
|
||||
return new Promise($promise, $this);
|
||||
}
|
||||
|
||||
public function all(array $promisesOrValues): Promise
|
||||
|
|
|
|||
Loading…
Reference in a new issue