Search code examples
kotlinkodein

How to pass parameter for Kodein Injected instances?


In Kodein, when I have the below binding

    bind<AppDependent>() with singleton {
        AppDependent("abc", instance(), instance())
    }

I could get my appDependent using below

private val appDependent : AppDependent by instance(

However if I like to provide the title as below

    bind<AppDependent>() with multiton {
        title: String -> AppDependent(title, instance(), instance())
    }

How could I create appDependent?

I tried something as below but not working.

private val appDependent : AppDependent by instance("Main")

Solution

  • Found that we could do it as below

    private val appDependent: AppDependent by instance(arg = "My Text")