run On Koin Started
Wait for all lazy module start jobs to complete, then run the given block.
This JVM-only function blocks the current thread until all lazy modules have finished loading, then executes the provided suspend block with the Koin instance.
Useful for scenarios where you need to perform actions after Koin is fully initialized, such as running startup tasks or initializing services that depend on all modules being loaded.
Parameters
block
Suspend lambda that receives the Koin instance once all start jobs complete
Example:
startKoin {
lazyModules(myLazyModule1, myLazyModule2)
}
KoinPlatform.getKoin().runOnKoinStarted { koin ->
// All modules are now loaded
koin.get<StartupService>().initialize()
}Content copied to clipboard
See also
for just waiting without executing code
for the suspend version