Created
January 3, 2018 21:59
-
-
Save amirkarimi/3f489525556ef8108cf962a2d1e7d7d1 to your computer and use it in GitHub Desktop.
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 getUser(id: Int): Future[Option[User]] = ??? | |
def getCity(user: User): Future[Option[City]] = ??? | |
def getCountry(city: City): Future[Option[Country]] = ??? | |
def getCountryByUserId(id: Int): Future[Option[Country]] = { | |
getUser(id) flatMap { | |
case None => Future.successful(None) | |
case Some(user) => | |
getCity(user) flatMap { | |
case None => Future.successful(None) | |
case Some(city) => getCountry(city) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment