From e34628f8f90295cf0a19e5cd2bcc4dd19000373b Mon Sep 17 00:00:00 2001 From: yuanzhihai <396751927@qq.com> Date: Thu, 10 Nov 2022 09:24:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http.php | 1 + src/Request.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/Http.php b/src/Http.php index 1be8dd0..fad314c 100644 --- a/src/Http.php +++ b/src/Http.php @@ -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 diff --git a/src/Request.php b/src/Request.php index da3e519..69f942d 100644 --- a/src/Request.php +++ b/src/Request.php @@ -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 );