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 myBusinessStuff(...) = { | |
| // Implementations and explicit names | |
| val action1 = ??? | |
| val action2 = ??? | |
| val action3 = ??? | |
| // What business people should almost be able to understand | |
| for { | |
| _ <- action1 |
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 shortCircuitFutureList[A](fs: List[() => Future[A]], cond: A => Boolean)( | |
| implicit executionContext: ExecutionContext): Future[A] = fs match { | |
| case tail :: Nil => tail() | |
| case head :: _ => | |
| head() | |
| .filter(cond) | |
| .recoverWith { | |
| case _ => shortCircuitFutureList(fs.tail, cond) | |
| } | |
| } |
OlderNewer