With the introduction of experimental api `onKoinS...
# koin
s
With the introduction of experimental api
onKoinStartup
, 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:
Copy code
open class MyApplication :
    Application() {
    override fun onCreate() {
        super.onCreate()
        initKoin(). // startKoin {} part
        CleverTapAPI.getDefaultInstance(applicationContext)?.setDisplayUnitListener(get<CleverTapBannerRemoteSource>())
    }
Now:
Copy code
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?
p
It should be coordinated with the Splash screen api