本文整理汇总了PHP中React\Promise\Deferred::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Deferred::__construct方法的具体用法?PHP Deferred::__construct怎么用?PHP Deferred::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类React\Promise\Deferred
的用法示例。
在下文中一共展示了Deferred::__construct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
/**
* Create a deferred promise for the response of $request
*
* @param API $api The endpoint of the request
* @param Client $client The HTTP client to send the request
* @param Request $request The request to execute
*/
function __construct(API $api, Client $client, Request $request)
{
$this->api = $api;
$this->client = $client;
$this->request = $request;
parent::__construct(function ($resolve, $reject) {
return $this->cancel($resolve, $reject);
});
$client->attach($this);
$client->enqueue($request, function (Response $response) {
$this->response = $response;
$this->complete([$this, "resolve"], [$this, "reject"]);
return true;
});
/* start off */
$client->once();
}