Created
February 29, 2020 22:57
-
-
Save joshafeinberg/88161f1c7fd25c87608ae80a131ba6fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Application.kodeinApplication( | |
kodeinMapper: Kodein.MainBuilder.(Application) -> Unit = {} | |
) { | |
val application = this | |
val kodein = Kodein { | |
bind<Application>() with instance(application) | |
kodeinMapper(this, application) | |
} | |
routing { | |
val sicknessService: SicknessService = findService(kodein) | |
val weightService: WeightService = findService(kodein) | |
val statsService: StatsService = findService(kodein) | |
retrofitService(service = Services( | |
sicknessService = sicknessService, | |
weightService = weightService, | |
statsService = statsService | |
)) | |
} | |
} | |
private inline fun <reified S : Any> findService(kodein: Kodein): S { | |
val service: S by kodein.instance() | |
return service | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment