Closed MrIceman closed 3 years ago
@akulinski What I don't like about koin is that it resolves dependencies at runtime and can cause unexpected bugs, Dagger on the other hand has a big overhead. What do you think about implementing an own factory per module which holds singleton instances of each repository? E.g.
object BankFactory { val repository: BankRepository by lazy { BankRepositoryImpl(**Injections**) }
After all, this is what Dagger generates and in a too complicated way imo.
i dont think we should do this because we have to look at it at scale and it 100 going to grow it best of we use dagger
I agree with @gzodx implementing this from scratch would be hard to scale. If koin causes unexpected bugs then I guess dagger is a better choice
Dagger is implemented in Java, our aim is to be multiplatform in future. What about a Kotlin solution? https://github.com/Kodein-Framework/Kodein-DI
Does anyone want to do some research and rate it?
I don't think dagger being written in java changes anything about it use in multiplaform ,my only problem with koin or Kodein are the fact that they are more of a service locator then a DI lib ,they do all their dependencies graph generation and all on run time which potentially can lead to runtime errors or slow down the app and the main concern once it begins to scale that when it becomes a big overhead to manage
We don't have to go through dagger 2 over head we can actually use hilt which take 90% of the boilerplate but if KMM if what our focus is then https://github.com/Kodein-Framework/Kodein-DI would be a better solution @MrIceman
@gzodx the issue with java code is that it requires a JVM which strikes out iOS and any other platform that has no JVM. Hilt is a wrapper over Dagger. Let's have a look at Kodein
Okey @MrIceman
Why don't we just delegate the dependency injection to each platform (i.e. Android and iOS) ?
The idea to focus on Android first then we target KMM
@IanArb from SDK point of view we should offer instances of the specific UseCases / Repositories already to the host app. So the HostApp at the end would only have to call something like
TNBClient.bankManager
and we'd provide the bank manager instance lazy
I can create this kind of solution. Will look at in the upcoming weeks and try to build custom factory(ish) pattern to resolve the current challenges and the future ones.
Hey @khurramsaeed feel free to take this one and looking forward to your solution!
Hey @khurramsaeed just checking in to see if you need any help?
Going to close this issue now. We'll be using Dagger.
@MrIceman do we want to use dagger or koin ?