rocketraman
12/23/2021, 11:13 PMorg.kodein.di:kodein-di-framework-compose
?sendoav
01/14/2022, 12:45 PMTomas Kormanak
02/04/2022, 2:22 PMinterface Handler {}
class SomeService(val handlers: List<Handler>) { ... }
di {
bind<Handler> { ActualHandler1() }
bind<Handler> { ActualHandler2() }
bind<SomeService> { SomeService(instance())}
}
Tomas Kormanak
02/11/2022, 10:53 AMinterface Feature1 {...}
interface Feature2 {...}
class Service(): Feature1,Feature2 {...}
di {
bind<Feature1> { singleton {Service()} }
bind<Feature2> { ... same singleton as above?? }
}
georgi
02/12/2022, 9:52 AM7.10.0
and it looks like the API for dependency injection changed and now I'm getting errors on the instance
methods. What is the new way of doing this? (I might have missed it in the docs!)Joost Klitsie
03/02/2022, 12:43 PMkhairil.ushan
03/02/2022, 8:32 PMankushg
03/03/2022, 1:18 AMrocketraman
03/03/2022, 5:06 PM// replace
bindSingleton { Foo(instance(), instance(), instance(), instance(), instance()) }
// with something like this
bindSingleton { ::Foo }
Botond Varsányi
04/01/2022, 1:39 PMPanagiotis Panos
04/13/2022, 1:22 PMjcechace
04/13/2022, 5:13 PMJoost Klitsie
04/27/2022, 1:57 PMsalomonbrys
06/08/2022, 2:50 PMJoost Klitsie
06/14/2022, 1:42 PMbindProvider { MyViewModel() }
and then using rememberViewModel()
(using Compose and android x viewmodel libraries)SrSouza
06/21/2022, 6:35 PM2 bindings found that match bind<X>
One of the bindings directly bind X
.
bind<X> scoped singleto { XImplementation()
another one uses X a delegate implementation.
class YViewModel(val x: X) : X by x
bind<YViewModel> scoped singleton { YViewModel(x = instance()) }
I try to use Bind(erased<YViewModel>())
but did not work, any workaround for this?
I don't want YViewModel to be considered X (by considered I mean not being accesible through instance<X>() = YViewModel
y9san9
06/22/2022, 10:20 AMromainbsl
06/22/2022, 11:27 AMYannick
06/28/2022, 4:20 PMCaused by: java.lang.RuntimeException: Invalid TypeToken; must specify type parameters
at org.kodein.type.TypeReference.<init>(Unknown Source:40)
at tb.b.<init>(Unknown Source:0)
at tb.n.invoke(Unknown Source:19)
at tb.a0.invoke(SourceFile:1)
I already added the following to my <http://proguard-rules.pro|proguard-rules.pro>
-keep class org.kodein.type.TypeReference { *; }
-keep class org.kodein.type.TypeToken { *; }
Also I can't access the docs regarding proguard https://docs.kodein.org/kodein-di/7.6/framework/android.html#_proguard_configuration Website seems to be downMatt Nelson
07/17/2022, 3:14 AMYousef
07/25/2022, 8:57 PMHylke Bron
08/11/2022, 12:56 PMUncaught Kotlin exception: kotlin.NullPointerException
at 0 LibName 0x102a360e2 kfun:kotlin.Exception#<init>(){} + 50
at 1 LibName 0x102a3616f kfun:kotlin.RuntimeException#<init>(){} + 31
at 2 LibName 0x102a53a35 ThrowNullPointerException + 165
at 3 LibName 0x102a63771 kfun:kotlin.collections.HashMap#get(1:0){}1:1? + 177
at 4 LibName 0x102be18e0 kfun:org.kodein.di.bindings.StandardScopeRegistry#getOrCreate(kotlin.Any;kotlin.Boolean;kotlin.Function0<org.kodein.di.bindings.Reference<kotlin.Any>>){}kotlin.Any + 304
at 5 LibName 0x102be42ca kfun:org.kodein.di.bindings.Singleton.$getFactory$lambda-3$FUNCTION_REFERENCE$90.invoke#internal + 650
at 6 LibName 0x102bdcb94 kfun:org.kodein.di.DIContainer.$provider$lambda-0$FUNCTION_REFERENCE$79.invoke#internal + 212
at 7 LibName 0x102bdc10d kfun:org.kodein.di.$Instance$lambda-0$FUNCTION_REFERENCE$78.invoke#internal + 1949
at 8 LibName 0x102bfb243 kfun:org.kodein.di.DIProperty.$provideDelegate$lambda-0$FUNCTION_REFERENCE$124.invoke#internal + 547
at 9 LibName 0x102a41708 kfun:kotlin.native.concurrent.SynchronizedLazyImpl#<get-value>(){}1:0 + 2024
at 10 LibName 0x102c139da kfun:my.company.name.<get-dependency>#internal + 186
The reproduction path is weird, we had to start, stop and start the application before it would crash. I dont have the time to distill a better reproduction path unfortunately, but i suspect it has something to do with race conditions while obtaining a singleton value. In my kotlin code I launch two coroutine jobs, which are executed as soon as the ios app starts:
coroutineScope {
launch { /*something that eventually will use the DI container; i.e. private val dependency: Dependency by instance()*/ }
launch { /*something that eventually will use the DI container; i.e. private val dependency: Dependency by instance()*/ }
}
I think this might be a concurrency issue with the native implementation of this library. Maybe its related to the fact that I am using the new experimental memory model. (which works fine by the way).
My current solution is that instead of binding instances with bindSingleton { instance }
, I now use bindEagerSingleton { instance }
. The fact that this solves my issue also points in the direction that there are some concurrency issues in the di library.
No need for direct assistence, but maybe if someone of the kodein team reads this they might gain some new insight.Tomas Kormanak
08/17/2022, 8:52 AMDependencyLoopException
We have a loop in dependencies which I think is alright in our case. We use construction injection (no DiAware interface). I was hoping that using a provider can solve it, but it seems not. Any ideas?
bind<EventBus>
╔╩>bind<Set<out EventHandler<in Event>>>
║ ╚>bind<NotificationService>
║ ╚>bind<EventBus>
╚══════╝
class LocalEventdBus: EventBus (
handlerProvider: () -> Set<EventHandler<Event>>,
) {...}
bindSingleton<EventBus> { LocalEventBus(provider()) }
František Jeřábek
08/29/2022, 5:55 PMkodein-di-framework-compose
library and when I try to attach the di to composable i am getting `content is not a function`error for some reason. The code is just simple composable.
@Composable
fun App() = withDI({
}) {
Text("Hello world")
}
I have these dependencies
implementation("org.kodein.di:kodein-di:7.12.0")
implementation("org.kodein.di:kodein-di-framework-compose:7.12.0")
The error looks like this
Uncaught TypeError: content is not a function
at CompositionLocalProvider$composable (CompositionLocal.kt?857d:228:5)
at withDI$composable (withDI.kt?309d:15:5)
at App$composable (Main.kt?7792:19:13)
at eval (Main.kt?7792:26:9)
at ComposableLambdaImpl.invoke_5qf8pc_k$ (ComposableLambda.js.kt?a45e:116:22)
at eval (KotlinRegulator.js:1163:25)
at eval (renderComposable.kt?e3c2:61:9)
at ComposableLambdaImpl.invoke_6harzl_k$ (ComposableLambda.js.kt?a45e:107:22)
at eval (web-internal-web-core-runtime.js:446:25)
at invokeComposable$composable (Composer.js.kt?6ed4:20:16)
I guess i am using something wrong, but i just cant figure out what it isAlper Tekin
09/01/2022, 1:24 PMbindSingleton() { HttpClient(CIO) }
(Auth module) then I set authentication token to the header using the singleton instance
val client: HttpClient by closestDI().instance()
client.config {
defaultRequest {
headers.append(HttpHeaders.Authorization, "$schemes $token")
}
(User module) Also, I have http clients that talk to each other in microservices. But it looks like I can’t set auth token to the same instance, no token is set in the header for the client below.
private val client: HttpClient by instance()
Kodein: 7.11.0
WDYT? Any suggestion?romainbsl
11/14/2022, 5:54 PMval di = DI {
bindSet<Configuration> {
add { provider { FooConfiguration() } }
bind { singleton { BarConfiguration() } }
}
}
The old API is now deprecated and should be removed in a future version.
Enjoy Kodein 7.16.0! And, of course, feedback is always welcome.Kazem Moridi
12/14/2022, 8:13 PMArjan van Wieringen
12/19/2022, 5:46 PMAlexSeleznev
02/07/2023, 3:11 PMbenkuly
02/17/2023, 4:48 PMbenkuly
02/17/2023, 4:48 PM