diff --git a/docs/reference/koin-android/start.md b/docs/reference/koin-android/start.md index 4946b9558..c79d978eb 100644 --- a/docs/reference/koin-android/start.md +++ b/docs/reference/koin-android/start.md @@ -72,19 +72,16 @@ startKoin { } ``` -## Start Koin with Androidx Startup (4.0) +## Start Koin with Androidx Startup (4.0.1) -By using Gradle packge `koin-androidx-startup`, we can use `onKoinStartup` function durectly in `init` block of your Application class: +By using Gradle packge `koin-androidx-startup`, we can use `KoinStartup` interface to declare your Koin configuration your Application class: ```kotlin class MainApplication : Application() { - init { - // Use AndroidX Startup for Koin - onKoinStartup { - androidContext(this@MainApplication) - modules(allModules) - } + override fun onKoinStartup(): KoinAppDeclaration = { + androidContext(this@MainApplication) + modules(appModule) } override fun onCreate() { @@ -96,5 +93,25 @@ class MainApplication : Application() { This replaces the `startKoin` function that is usally used in `onCreate`. :::info -Gain over from `onKoinStartup` to regular `startKoin` can go over 30% of time gained, for startup time. +Gain over from `KoinStartup` to regular `startKoin` can go over 30% of time gained, for startup time. ::: + +## Startup Dependency with Koin + +You can make your `Initializer` depend on `KoinInitializer` if you need Koin to be setup, and allow to inject dependencies: + +```kotlin +class CrashTrackerInitializer : Initializer, KoinComponent { + + private val crashTrackerService: CrashTrackerService by inject() + + override fun create(context: Context) { + crashTrackerService.configure(context) + } + + override fun dependencies(): List>> { + return listOf(KoinInitializer::class.java) + } + +} +``` \ No newline at end of file