scala - 与 Play 集成时,此应用程序如何从 IOConnection/IO 转换为未来?
问题描述
我正在 github 上查看这个同时使用 play 和 doobie 的 repo。
我想了解它最终是如何从猫的 connectionIO/IO 转换为构建 playframework 的 Future 的。
我正在查看一个控制器,我可以看到 userRepo,但我看不到它从期货到 IO 的去向或方式。
def doEdit(): Action[AnyContent] = UserAction { implicit req =>
GsForms.user.bindFromRequest.fold(
formWithErrors => editView(formWithErrors),
data => userRepo.edit(data)
.map(_ => Redirect(PublishedSpeakerRoutes.detail(req.user.slug)).flashing("success" -> "Profile updated"))
)
}
解决方案
unsafeToFuture
最终会有一个呼叫
评估效果并在 Future 中产生结果。
在UICtrl.scala#L59行。这些问题最好通过IDE的Goto 定义功能来回答。例如,Metals 为所有主要编辑提供它。通常快捷方式是符号名称command+click
或control+click
符号名称。
推荐阅读
- spring-cloud-dataflow - org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; 错误的 SQL 语法 [SELECT DEFINITION_NAME, DEFINITION FROM TASK_DEFINITIONS
- python - 一个变量是否有可能识别出它持有一个字典变量并相应地使用它
- c# - ASP.NET Core JWT 令牌无法通过 HttpClient 工作
- python - 代码注入程序面临问题。该程序未显示 http 网站的 HTML 代码
- java - 布局日历事件
- linux - 获取隐藏文件的统计信息(ls 或 cp)
- excel - 过滤单元格作为公式中函数的参数
- mysql - XAMPP MySQL 意外关闭
- c# - 问题,VS 19 ASP.NET Core 3.1,当我开始创建“带有视图的 MVC 控制器,使用实体框架”
- javascript - 如何从扩展中获取名称和版本(附加组件)