Thread
#multiplatform
    Kweku

    Kweku

    2 years ago
    How is everyone currently handling dependency Injection? The app I'm working on for Android and IOS use KMP for the domain and data layers then Flutter for the UI. I was thinking of handling DI outside of KMP, for exame using dagger for Android as in native Android I've mages to use Dagger in a way where my domain and data layers have no dependencies on Dagger. The problem is I'm unsure about doing this for Ios having never developed for it before although I've read Needle and Dagger are similar? I've seen Koin( which I've used before) and KodeIn (which I haven't) be mentioned but haven't seen any example usage and theres also the option of doing it myself(Pure DI) Basically I've done a some research but it's the native part that is making me wary as I've seen things about concurrency issues TDLR: I'd like to know if anyone has any experience with DI on KMP
    j

    judrummer

    2 years ago
    I use Kodein
    russhwolf

    russhwolf

    2 years ago
    We’re using Koin in KaMPKit if you want to see some sample usage. Note that this is actually an internal fork to better handle native threading, which will be upstreamed in a future Koin release. Common: https://github.com/touchlab/KaMPKit/blob/master/shared/src/commonMain/kotlin/co/touchlab/kampstarter/Koin.kt Platforms: https://github.com/touchlab/KaMPKit/blob/master/shared/src/iosMain/kotlin/co/touchlab/kampstarter/KoiniOS.kt and https://github.com/touchlab/KaMPKit/blob/master/shared/src/androidMain/kotlin/co/touchlab/kampstarter/KoinAndroid.kt
    Kweku

    Kweku

    2 years ago
    @russhwolf thank you, you mean the one by @kpgalligan ? I'm guessing you cal initKoin in the Application/ MainActivity or AppDelegate but what is the appDeclaration parameter and the type (KoinAppDeclaration ={}) ?
    russhwolf

    russhwolf

    2 years ago
    Brendan Weinstein

    Brendan Weinstein

    2 years ago
    I am doing manual for the short-to-medium-run future
    Kweku

    Kweku

    2 years ago
    @russhwolf ahh that makes sense, what issues are there witch concurrency etc
    @Brendan Weinstein how are you finding that?
    saket

    saket

    2 years ago
    I've a similar setup like @russhwolf: Koin in common code, Dagger in Android. You can take a look here: https://github.com/saket/press
    Kweku

    Kweku

    2 years ago
    @saket why both Koin and Dagger rather than just Dagger in Android?
    saket

    saket

    2 years ago
    Not sure if i understood your question. Koin is only used in common code written with kotlin multiplatform.
    Brendan Weinstein

    Brendan Weinstein

    2 years ago
    @Kweku I am using multiplatform on a smaller-to-midsize project, so it's not that bad.
    c

    coletz

    2 years ago
    I am using koin for a mpp project, basically copied kamp kit code. For a mpp + flutter project like yours, no DI at all. Honestly having two totally separated code bases (different lang) I wasn't sure DI was worth for such a small project