Skip to content

Commit 8207291

Browse files
committed
Promise api doc tweaks
1 parent ad8256d commit 8207291

1 file changed

Lines changed: 14 additions & 23 deletions

File tree

README.md

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ $resolver = $deferred->resolver();
8888
```
8989

9090
Although a Deferred has the full Promise + Resolver API, this should be used for
91-
convenience only by the creator of the deferred. Only the promise and resolver
91+
convenience only by the creator of the deferred. Only the Promise and Resolver
9292
should be given to consumers and producers.
9393

9494
``` php
@@ -105,37 +105,28 @@ $deferred->progress(mixed $update = null);
105105
The Promise represents the eventual outcome, which is either fulfillment
106106
(success) and an associated value, or rejection (failure) and an associated
107107
reason. The Promise provides mechanisms for arranging to call a function on its
108-
value or reason, and produces a new promise for the result.
108+
value or reason, and produces a new Promise for the result.
109109

110110
A Promise has a single method `then()` which registers new fulfilled, error and
111111
progress handlers with this Promise (all parameters are optional):
112112

113113
``` php
114-
$promise->then(callable $fulfilledHandler = null, callable $errorHandler = null, callable $progressHandler = null);
114+
$newPromise = $promise->then(callable $fulfilledHandler = null, callable $errorHandler = null, callable $progressHandler = null);
115115
```
116116

117-
As per the Promises/A spec, `then()` returns a new Promise that will be resolved
118-
with the return value of `$fulfilledHandler` if Promise is fulfilled, or with
119-
the return value of `$errorHandler` if Promise is rejected.
117+
* `$fulfilledHandler` will be invoked once the Promise is fulfilled and passed
118+
the result as the first argument.
119+
* `$errorHandler` will be invoked once the Promise is rejected and passed the
120+
reason as the first argument.
121+
* `$progressHandler` will be invoked whenever the producer of the Promise
122+
triggers progress notifications and passed a single argument (whatever it
123+
wants) to indicate progress.
120124

121-
A Promise starts in an unresolved state. At some point the computation will
122-
either complete successfully, thus producing a result, or fail, either
123-
generating some sort of error why it could not complete.
125+
Returns a new Promise that will fulfill with the return value of either
126+
`$fulfilledHandler` or `$errorHandler`, whichever is called, or will reject with
127+
the thrown exception if either throws.
124128

125-
If the computation completes successfully, the Promise will transition to the
126-
resolved state and the `$fulfilledHandler` will be invoked and passed the
127-
result as the first argument.
128-
129-
If the computation fails, the Promise will transition to the rejected
130-
state and `$errorHandler` will be invoked and passed the error as the first
131-
argument.
132-
133-
The producer of this Promise may trigger progress notifications to
134-
indicate that the computation is making progress toward its result.
135-
For each progress notification, `$progressHandler` will be invoked and
136-
passed a single argument (whatever it wants) to indicate progress.
137-
138-
Once in the resolved or rejected state, a Promise becomes immutable.
129+
Once in the fulfilled or rejected state, a Promise becomes immutable.
139130
Neither its state nor its result (or error) can be modified.
140131

141132
A Promise makes the following guarantees about handlers registered in

0 commit comments

Comments
 (0)