Explore the possibility of "functional definitions" in DI #65
Labels
experiments
This issue or PR is about an experimental (or would-be experimental) feature
Module: tegral-di
Module: tegral-web-controllers
Milestone
The idea is to be able to define DI components as functions. This would unlock more advanced use cases, an obvious one being easier definition of simple web controllers and Ktor modules.
Usage
Here's an example of what this could look like.
Tegral Web Controllers
For example:
Tegral DI
Pros, cons and remarks
Pros
Indentiation
Saves an indentation space for controllers and modules and significantly simplifies their definition.
Ktor modules
Misc.
scope.optional()
) can easily be supported by using default parameters! (probably with nullable support, soA? = null
in a parameter would be the same asenv.getOrNull<A>()
)Cons
Qualifiers
put
syntax, becomes constructors are considered functions when using reflection. Either<KFunction object>.javaConstructor != null
.Remarks
init
block.Todo list
putFundef
putFundef
intoput
Drop annotation requirementsee belowThe text was updated successfully, but these errors were encountered: