PluginProbe
WP-Stateless – Google Cloud Storage / 2.1.4
WP-Stateless – Google Cloud Storage v2.1.4
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / Google / vendor / react / promise / src / Deferred.php

Deferred.php in WP-Stateless – Google Cloud Storage 2.1.4, at lib/Google/vendor/react/promise/src/Deferred.php

61 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace React\Promise;
4
5 class Deferred implements PromisorInterface
6 {
7 private $promise;
8 private $resolveCallback;
9 private $rejectCallback;
10 private $notifyCallback;
11 private $canceller;
12
13 public function __construct(callable $canceller = null)
14 {
15 $this->canceller = $canceller;
16 }
17
18 public function promise()
19 {
20 if (null === $this->promise) {
21 $this->promise = new Promise(function ($resolve, $reject, $notify) {
22 $this->resolveCallback = $resolve;
23 $this->rejectCallback = $reject;
24 $this->notifyCallback = $notify;
25 }, $this->canceller);
26 }
27
28 return $this->promise;
29 }
30
31 public function resolve($value = null)
32 {
33 $this->promise();
34
35 call_user_func($this->resolveCallback, $value);
36 }
37
38 public function reject($reason = null)
39 {
40 $this->promise();
41
42 call_user_func($this->rejectCallback, $reason);
43 }
44
45 public function notify($update = null)
46 {
47 $this->promise();
48
49 call_user_func($this->notifyCallback, $update);
50 }
51
52 /**
53 * @deprecated 2.2.0
54 * @see Deferred::notify()
55 */
56 public function progress($update = null)
57 {
58 $this->notify($update);
59 }
60 }
61