Running your modules
One you have declared your dependencies with the Koin DSL, you just need to start Koin and inject!
The start function
startKoin() function just need a list of
Module to run and it will load every defintion from your modules. It is a function, it can be used every where, dependening on the used runtime. But it can be use only once.
External properties can be loaded while starting your modules.
Load from koin.properties
Koin will check if koin.properties is available, to load your properties. It has to be in
src/main/resources Kotlin folder or
asset Android folder.
For koin core/spark/ktor, you can also load environment properties with the
You can also supply properties on the fly, with the Koin start function with the
Depending on your chosen Koin module, Koin will be launched slightly differently.
For a Kotlin app, just start it in your
For an Android app, you will start Koin in your
For a Spark web app, just run it from your
Loading Koin modules without starting Koin?
When developing library or sub modules, you don’t have the application entry point, but you can have the need to use Koin with some of your modules.
loadKoinModules to load Koin modules (
vararg). It will start Koin if not already started.
Your dependencies are delcared in modules. You have started Koin. Let’s go with injection!