1

I'm looking at this repo on github that is using both play and doobie.

I want to understand how it is eventually converting from a connectionIO/IO from cats to a Future that the playframework is built around from.

I'm looking at a controller and I can see the userRepo but I don't see where or how it is going to/from futures to 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"))
    )

}

https://github.com/gospeak-io/gospeak/blob/36fd9dd4ebe314c2ca8e02e2e2c714b6d399d045/web/app/gospeak/web/pages/user/profile/ProfileCtrl.scala#L28

Blankman
  • 259,732
  • 324
  • 769
  • 1,199

1 Answers1

2

Eventually there is a call to unsafeToFuture which

Evaluates the effect and produces the result in a Future.

at line UICtrl.scala#L59. These questions are best answered by Goto definition feature of IDE. For example, Metals provides it for all major editors. Often the shortcut is command+click or control+click on the symbol name.

enter image description here

Mario Galic
  • 47,285
  • 6
  • 56
  • 98
  • oh I see, so everything can be cats "friendly" until the last moment when you need to return Play's action results. So they just created custom Action results which perform the conversion there, got it! – Blankman Aug 03 '20 at 17:09