@@ -98,6 +98,10 @@ The `await(PromiseInterface $promise, LoopInterface $loop)` method can be used t
9898$result = Block\await($promise, $loop);
9999```
100100
101+ Once the promise is resolved, this will return whatever the promise resolves to.
102+
103+ If the promises is being rejected, this will fail and throw an ` Exception ` .
104+
101105``` php
102106try {
103107 $value = Block\await($promise, $loop);
@@ -119,25 +123,37 @@ $promises = array(
119123 $promise2
120124);
121125
122- $result = Block\awaitAny($promises, $loop);
126+ $firstResult = Block\awaitAny($promises, $loop);
127+
128+ echo 'First result: ' . $firstResult;
123129```
124130
125- Once the first promise is resolved, this will try to cancel() all
126- * remaining promises and return whatever the first promise resolves to.
127- *
128- * If ALL promises fail to resolve, this will fail and throw an Exception.
131+ Once the first promise is resolved, this will try to ` cancel() ` all
132+ remaining promises and return whatever the first promise resolves to.
133+
134+ If ALL promises fail to resolve, this will fail and throw an ` Exception ` .
129135
130136#### awaitAll()
131137
132138The ` awaitAll(array $promises, LoopInterface $loop) ` method can be used to wait for ALL of the given promises to resolve.
133139
140+ ``` php
141+ $promises = array(
142+ $promise1,
143+ $promise2
144+ );
145+
146+ $allResults = Block\awaitAll($promises, $loop);
147+
148+ echo 'First promise resolved with: ' . $allResults[0];
149+ ```
134150
135151Once the last promise resolves, this will return an array with whatever
136- * each promise resolves to. Array keys will be left intact, i.e. they can
137- * be used to correlate the return array to the promises passed.
138- *
139- * If ANY promise fails to resolve, this will try to cancel() all
140- * remaining promises and throw an Exception.
152+ each promise resolves to. Array keys will be left intact, i.e. they can
153+ be used to correlate the return array to the promises passed.
154+
155+ If ANY promise fails to resolve, this will try to ` cancel() ` all
156+ remaining promises and throw an ` Exception ` .
141157
142158## Install
143159
0 commit comments