This file contains 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
/** | |
* Use cats applicative | |
*/ | |
import cats.syntax.all._ | |
import cats.instances.future._ | |
val start3: Instant = Instant.now | |
val fUserInfo3 = for { | |
nickname <- getNicknameById(userId) | |
(email, account) <- (getEmailAddressByNickname(nickname) |@| getAccountInfoByNickname(nickname)).tupled | |
} yield UserInfo(userId, nickname, email, account) | |
val userInfo3: UserInfo = Await.result(fUserInfo3, 10 second) | |
val end3: Instant = Instant.now | |
println(printInterval(userInfo3, start3, end3)) // UserInfo(31337,ktz,helloworld@example.com,None) take 5 seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment