hello there! is there assisted injection in Koin? ...
# koin
m
hello there! is there assisted injection in Koin? Lets say I have
Service
which needs
userId
to be created but we don’t have userId until we call a resource. how is the best way to workaround it? 🙏🏻
c
Yup assisted injection has been around for a long while: https://insert-koin.io/docs/reference/koin-android/entry-points#with-parameters
🖤 1
c
Does the constructor reference syntax remove the need to explicitly declare the "assisted" parameters? Looking at the example in the link above, I would have assumed that this
Copy code
val appModule = module {
    factoryOf(::UserDetailPresenter)
}
Should have been this
Copy code
val appModule = module {
    factory { (userId: String) ->
        UserDetailPresenter(
            userId = userId,
            foo = get(),
            bar = get()
        )
    }
}
👌 1
g
c
Yes, you can still do factoryOf(::SomeClass), so long as you provide a parametersOf at the injection site. No need to explicitly define the parameters in the module
👍🏽 1
You only need to use the InjectedParam, if you are using koin annotations. In which case, you wouldn't be declaring the module with constructor injection
m
than you all kodee happy