Created
November 3, 2016 02:15
-
-
Save JavadocMD/3a5aec9fe5b1de89c96877ac6fcc095b to your computer and use it in GitHub Desktop.
Sequence of Futures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def details(since: Option[LocalDate], until: Option[LocalDate], page: Int): Future[NumberedDetailsPage] = { ... } | |
details(since, until, 1).flatMap { page1 => | |
val pagesFuture = Future.sequence( | |
for { | |
n <- (2 to page1.details.totalPages).toList | |
} yield { | |
details(since, until, n) | |
} | |
) | |
pagesFuture.map(pages2toN => (page1 :: pages2toN).map(_.details.data).flatten) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment