Hello, how would I go about binding different impl...
# koin
c
Hello, how would I go about binding different implementations based on an environment variable?
n
Something like this?
Copy code
single<ServiceInterface> {
  if (System.getenv("...") == ...) ServiceImpl1() else ServiceImpl2()
}
p
We inject the environment variable as a
BuildConfig
field in our Android code, then use it to optionally include different modules -
Copy code
object NetworkingKoinConfig {
    val modules = listOf(
        apiErrorModule,
        okHttpModule,
        retrofitModule,
        if(BuildConfig.NEW_FEATURE_ENABLED) updatedModule else oldModule
    )
}
Then we aggregate together these various module lists to configure Koin.