nimrod
12/16/2020, 2:48 PMnimrod
12/16/2020, 3:58 PMsalomonbrys
12/16/2020, 4:02 PMnimrod
12/16/2020, 4:10 PMnimrod
12/16/2020, 4:14 PMsalomonbrys
12/16/2020, 4:15 PMnimrod
12/16/2020, 5:33 PMsalomonbrys
12/16/2020, 6:18 PMsalomonbrys
12/16/2020, 6:22 PMEnvironmentScope
that do not clear the memory when changing environment, and a more complex OneEnvironmentScope
that do clear the memory when changing scope.
Note that this sample is for JVM only. I could adapt it to KMP, if you need me to.nimrod
12/17/2020, 3:38 PMDebugHelper
. which is also provided via Kodein. How should I get it for calling registerContextFinder()
?nimrod
12/17/2020, 3:39 PMval applicationModule: DI.Module = DI.Module("ApplicationModule") {
// How to get debugHelper instance here?
registerContextFinder<Environment> { debugHelper.env }
bind() from scoped(OneEnvironmentScope).singleton {
// instance setup here
}
}
salomonbrys
12/18/2020, 9:26 AMsalomonbrys
12/18/2020, 9:29 AMlateinit var di: DI
di = DI {
bind() from singleton { CurrentEnvironment(Environment.PROD) }
// Choose one:
//bind() from scoped(EnvironmentScope).singleton { API(context.baseUrl) }
bind() from scoped(OneEnvironmentScope).singleton { API(context.baseUrl) }
// This is needed to provide Kodein-DI the mean to find the current env.
registerContextFinder<Environment> { di.direct.instance<CurrentEnvironment>().env }
}
nimrod
12/18/2020, 12:45 PMDI.Module("ApplicationModule") {
which doesn’t seem to have access to direct
. Am I missing something?salomonbrys
12/18/2020, 12:47 PMnimrod
12/18/2020, 12:50 PM