Paolo Pasianot
07/03/2025, 3:58 PMOlivier Patry
07/03/2025, 5:01 PMOlivier Patry
07/03/2025, 5:01 PMQWQ
07/04/2025, 3:47 AMVidmantas Kerbelis
07/04/2025, 6:11 AMcommonMain:
expect fun createPlatformModule(): Module
androidMain:
actual fun createPlatformModule(): Module = module {
single<Foo> { AndroidFoo(context = get()) }
}
iosMain:
actual fun createPlatformModule(): Module = module {
single<Foo> { IosFoo() }
}
Dont' forget to pass the androidContext in startKoin
on the Android's side.
startKoin {
androidContext(...)
}
If you have startKoin
in a shared place, expose a lambda KoinApplication.() -> Unit
to be able to add additional modules for a specific platform.
fun initialize(action: KoinApplication.() -> Unit) {
startKoin {
action()
modules(
listOf(createPlatformModule(), ...)
)
}
}
Paolo Pasianot
07/04/2025, 7:09 AM