add Futures.promise to the docs
This commit is contained in:
parent
325ea283cb
commit
e6655ec157
4 changed files with 25 additions and 2 deletions
|
|
@ -399,15 +399,21 @@ class FutureDocSpec extends AkkaSpec {
|
|||
}
|
||||
}
|
||||
|
||||
"demonstrate usage of Future.successful & Future.failed" in {
|
||||
"demonstrate usage of Future.successful & Future.failed & Future.promise" in {
|
||||
//#successful
|
||||
val future = Future.successful("Yay!")
|
||||
//#successful
|
||||
//#failed
|
||||
val otherFuture = Future.failed[String](new IllegalArgumentException("Bang!"))
|
||||
//#failed
|
||||
//#promise
|
||||
val promise = Promise[String]()
|
||||
val theFuture = promise.future
|
||||
promise.success("hello")
|
||||
//#promise
|
||||
Await.result(future, 3 seconds) must be("Yay!")
|
||||
intercept[IllegalArgumentException] { Await.result(otherFuture, 3 seconds) }
|
||||
Await.result(theFuture, 3 seconds) must be("hello")
|
||||
}
|
||||
|
||||
"demonstrate usage of pattern.after" in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue