-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Description
There are some Action construct methods.
def apply(block: R[B] => Result): Action[B] =
def apply(block: => Result): Action[AnyContent] =
def async(block: => Future[Result]): Action[AnyContent] =
def async(block: R[B] => Future[Result]): Action[B] =
def async[A](bodyParser: BodyParser[A])(block: R[A] => Future[Result]): Action[A] =some common use cases request implicit variable not reference explicit in Action.
class MyController {
def hello(id: Int): Action[AnyContent] = Action { implicit request =>
obj.myMethodImplicitRequest(id)
}
}def myMethodImplicitRequest(id: Int)(implicit request: Request[?]) =I think this is proper use case Scala 3 context function.
We can remove boilerplate implicit request => by context function.
https://docs.scala-lang.org/scala3/reference/contextual/context-functions.html
class MyController {
+ def hello(id: Int): Action[AnyContent] = Action.someContextFunctionMethod {
- def hello(id: Int): Action[AnyContent] = Action { implicit request =>
obj.myMethodImplicitRequest(id)
}
}We should add new name method in src/main/scala-3 instead of apply or async overloads but I can’t think of good method name.
WDYT?
I have added some context function methods in scalikejdbc because there is similar use case
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels