Skip to content

Commit

Permalink
修复 异步返回
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanzhihai committed Nov 10, 2022
1 parent aa7f805 commit e34628f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* @method static \yzh52521\EasyHttp\Request headAsync(string $url, array|null $data = null, callable $success = null, callable $fail = null)
* @method static \yzh52521\EasyHttp\Request optionsAsync(string $url, array|null $data = null, callable $success = null, callable $fail = null)
* @method static \yzh52521\EasyHttp\Request multiAsync(array $promises, callable $success = null, callable $fail = null)
* @method static \yzh52521\EasyHttp\Request wait()
*/

class Http extends Facade
Expand Down
8 changes: 8 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,14 @@ protected function requestAsync(
}
}

public function wait()
{
if (!empty($this->promises)) {
Promise\settle($this->promises)->wait();
}
$this->promises = [];
}

protected function response($response)
{
return new Response( $response );
Expand Down

0 comments on commit e34628f

Please sign in to comment.