Skip to content

Fix syntax for the Future andThen combinator #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ja/overviews/core/futures.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,13 @@ Future は同じ `Throwable` とともに失敗する。
ソーシャルネットワークからの最近の投稿文を可変セットに保存して、全ての投稿文を画面に表示する以下の具体例をみてみよう:

val allposts = mutable.Set[String]()

Future {
session.getRecentPosts
} andThen {
posts => allposts ++= posts
case Success(posts) => allposts ++= posts
} andThen {
posts =>
case _ =>
clearAll()
for (post <- allposts) render(post)
}
Expand Down
6 changes: 3 additions & 3 deletions overviews/core/_posts/2012-09-20-futures.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,13 @@ which stores the recent posts from a social network to a mutable set
and then renders all the posts to the screen:

val allposts = mutable.Set[String]()

Future {
session.getRecentPosts
} andThen {
posts => allposts ++= posts
case Success(posts) => allposts ++= posts
} andThen {
posts =>
case _ =>
clearAll()
for (post <- allposts) render(post)
}
Expand Down
6 changes: 3 additions & 3 deletions sips/completed/_posts/2012-01-21-futures-promises.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@ which stores the recent posts from a social network to a mutable set
and then renders all the posts to the screen:

val allposts = mutable.Set[String]()

Future {
session.getRecentPosts
} andThen {
posts => allposts ++= posts
case Success(posts) => allposts ++= posts
} andThen {
posts =>
case _ =>
clearAll()
for (post <- allposts) render(post)
}
Expand Down
8 changes: 4 additions & 4 deletions zh-cn/overviews/core/futures.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ fallbackTo组合器生成的future对象可以在该原future成功完成计算
组合器andThen的用法是出于纯粹的side-effecting目的。经andThen返回的新Future无论原Future成功或失败都会返回与原Future一模一样的结果。一旦原Future完成并返回结果,andThen后跟的代码块就会被调用,且新Future将返回与原Future一样的结果,这确保了多个andThen调用的顺序执行。正如下例所示,这段代码可以从社交网站上把近期发出的帖子收集到一个可变集合里,然后把它们都打印在屏幕上:

val allposts = mutable.Set[String]()
future {

Future {
session.getRecentPosts
} andThen {
posts => allposts ++= posts
case Success(posts) => allposts ++= posts
} andThen {
posts =>
case _ =>
clearAll()
for (post <- allposts) render(post)
}
Expand Down