how do I best configure my koin dependencies based on a setting? E.g. I might want to have a development setting using a memory database and a production setting using the actual database. In Spring I'd usually solve this using profiles
a
arnaud.giuliani
06/12/2024, 2:10 PM
we don't have profile in Koin, which could be intersting. You can manually use Kotlin expressions to load definitions depending on a boolean expression in a module:
arnaud.giuliani
06/12/2024, 2:10 PM
Copy code
val myModule = module {
if (isDev) {
// definitions
} else {
// other definitions
}
}
@arnaud.giuliani I'd avoid boolean flag at almost any cost 😛 that said, it's trivial to do as proper enums (which is the correct and natural choice anyway)
Rohde Fischer
06/12/2024, 6:18 PM
and I guess having that would do the trick in a decent way, although I think a profile-ish structure would be nice, since having conditional logic like that will become messy quite fast