碰到一个问题我还没找到答案.
使用Scala在playframework 2上运行.
需要编写一个执行多个Future调用的Action方法.我的问题:1)附加的代码是否是非阻塞的,因此看起来应该如何?2)是否保证在任何给定时间都捕获两个DAO结果?
def index = Action.async {
val t2:Future[Tuple2[List[PlayerCol],List[CreatureCol]]] = for {
p <- PlayerDAO.findAll()
c <- CreatureDAO.findAlive()
}yield(p,c)
t2.map(t => Ok(views.html.index(t._1, t._2)))
}
Run Code Online (Sandbox Code Playgroud)
感谢您的反馈意见.