Hello i just started exploring dependency injectio...
# kotlin-native
m
Hello i just started exploring dependency injection in hybdrid, app any one tried kodein alongside with kotlin native? does it work in ios app?
u
It worked for me in a simple test case. I just had some problems with initialization order but that was not strictly related to kodein. On jvm static members of a class are initialized during class loading, which usually happens during first access of the class. This is not true for native, nor for js.
l
@uli What happens on Native and on JS instead?
u
I have no idea. On native i expect linking order to determine the initialization order. But this is just a guess. Probably you should not rely on any order. I went for lazy vars to solve my Problem
m
Hello thank you for your feedback, i dont know if it would work for a big project but since i dont know any other framework for DI that work for both ios and android i will dig a litle more
u
please let us know - thanks
m
Hello back from my testing
i have something like this
val kodeinTest = Kodein { bind<String>("string") with singleton { "this is a test string" } } val string : String by kodeinTest.instance("string")
is there a way to pass an argument to my binder created from my activity?
i did something like
but when i try LeaderboardDI.Companion.getLeaderboardController(displayer: self).loadScore() in ios it does not work 😕
never mind i removed the companion object
a @ThreadLocal on my companion object also did the job