Not sure if I'm thinking about this the right way....
# koin
j
Not sure if I'm thinking about this the right way....but is there any way in Koin, if you have say an
initKoin
function being invoked from iOS code, to pass in an instance of a Swift class that becomes part of the koin object graph? Perhaps not a factor here but that Swift class implements a Kotlin interface in the scenario I have in mind.
1
p
No like a expect and then actual from each platform ?
c
Doesn't it already work that way? You can pass an instance of a Swift class and on the Kotlin side you can
single <FooInterface> { objectPassedInFromSwift }
j
hmm, yeah maybe that's all that needed....I could easily be overthinking this....
In kotlin-inject for example you can have a per platform "component" ....and can pass in an instance when creating say the iOS one that overrides variable declared in base (common) component
I'll play around with it a bit more
c
FWIW we are doing exactly what I describe above and it works well. You do need a bit of koin
module{}
management and perhaps some expect/actuals (to make sure the JVM/Android/whatever other platform gets a suitable implementation as well)
👍 1
1
p
I do it with expect and actual on each platform and you can use annotations. i.e
but I guess in you case is better to have a NativeModule so in ios you can have the expected dependency on each platform