Skip to content

Instantly share code, notes, and snippets.

@halimbimantara
Last active February 16, 2020 10:13
Show Gist options
  • Save halimbimantara/908f7c8558963962cf3591f1fcaac6f2 to your computer and use it in GitHub Desktop.
Save halimbimantara/908f7c8558963962cf3591f1fcaac6f2 to your computer and use it in GitHub Desktop.
[Migrating from Dagger2 to Koin ]#Android #Kotlin #Koin

Migrating from Dagger2 to Koin

Installing Koin

I started adding the Koin dependency like below :

dependencies {
  // KOIN
  implementation "org.koin:koin-android:1.0.2"
}

That’s it. Pretty light compared to Dagger2. Because Koin doesn’t use the annotation processing, you don’t have to use the kapt compiler plugin and worry about it.

1. Creating Module

For the NoBullshit Android application, I only had a single & simple Dagger2 module providing Firestore datasource :

@Module
class DataModule {
    @Provides
    fun provideFirestore(): FirebaseFirestore = FirebaseFirestore.getInstance()

    @Singleton
    @Provides
    fun provideJobDao(firestore: FirebaseFirestore): JobDao = JobDao(firestore)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment