Sonu Sourav
03/27/2025, 1:51 PMonKoinStartup
, koin initialisation and loading/unloading of modules is moved away from main thread. But my doubt is what will happen if for some reason, the dependency does not get initialised by the time I am injecting and using it. For e.g.
Earlier:
open class MyApplication :
Application() {
override fun onCreate() {
super.onCreate()
initKoin(). // startKoin {} part
CleverTapAPI.getDefaultInstance(applicationContext)?.setDisplayUnitListener(get<CleverTapBannerRemoteSource>())
}
Now:
open class MyApplication :
Application(), KoinStartup {
override fun onCreate() {
super.onCreate()
CleverTapAPI.getDefaultInstance(applicationContext)?.setDisplayUnitListener(get<CleverTapBannerRemoteSource>())
}
@KoinExperimentalAPI
override fun onKoinStartup() = koinConfiguration {} // module loading and unloading
In above case, since initKoin
was happening first, it was sure that CleverTapBannerRemoteSource
would be available before I use it, but how can we ensure that after startup update?
Also, is there any way we can get some callback, when onKoinStartup
has finished it job?Pablichjenkov
03/27/2025, 2:04 PM