Permalink
Browse files

Merge pull request #102 from phaller/patch-1

SIP-14: Update text about `onComplete`, `onSuccess`, and `onFailure` (result typ...
  • Loading branch information...
2 parents 2246b03 + 0ada843 commit f15d6c793948483dc9d1e8fd22e540ad7749b6fa @heathermiller heathermiller committed Jul 18, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 sips/pending/_posts/2012-01-21-futures-promises.md
@@ -131,14 +131,18 @@ To handle failed results, the `onFailure` callback is used:
f onFailure {
case t => render("An error has occured: " + t.getMessage)
- } onSuccess {
+ }
+ f onSuccess {
case posts => for (post <- posts) render(post)
}
The `onFailure` callback is only executed if the future fails, that
is, if it contains an exception. The `onComplete`, `onSuccess`, and
-`onFailure` methods return the receiver (the future), which allows
-registering multiple callbacks by chaining invocations.
+`onFailure` methods have result type `Unit`, which means invocations
+of these methods cannot be chained. This is an intentional design
+decision which was made to avoid suggesting that chained
+invocations may imply an ordering on the execution of the registered
+callbacks (callbacks registered on the same future are unordered).
Since partial functions have the `isDefinedAt` method, the
`onFailure` method only triggers the callback if it is defined for a

0 comments on commit f15d6c7

Please sign in to comment.