How do you guys do DI? Manually with by lazy?
# kotlin-native
u
How do you guys do DI? Manually with by lazy?
w
I use redux so I have a single dependency container inside the store. I use koin just to inject the Context from the android app code
a
Manual DI via constructors. I decompose my code by small modules so there is no mess with dependencies. In this case they are easy to control without DI framework. And you get all benefits of both compile time safety and click-navigation throughout the code.
👍 1
k
Dagger for android and needle by Uber and manual di via functions for things that can't be passed I from swift code for IOS, but planning to find a way to use the same DI for common code and using Dagger and needle for the platform specific stuff to cut down on boilerplate
u
Hmm in confused, so you dont include DI framework in your modules, only in the final app module which is platform specific anyways?
a
Koin for me, its pretty simple and seems to do the job. I never got around to trying dagger and heard mixed things about it.
u
and do you put koin modules inside library modules? or are they all only in :app module (but the library classes are still in the library)
h
Here is some more info on Manual injection. It's pretty straightforward. I've heard good things about Koin as well.

https://www.youtube.com/watch?v=ucZnYS7LmGU

u
I'm aware, but, what the difference between your sdk and retrofit? that your sdk has ui? whats the threshold of manging your own library graph, opposed to leaving the clients to plug your stuff into their graph -- also, what if the module is 1st party
@handstandsam I'm looking at the shopping cart sample, and you have all DI code in :app so yea, this doesnt apply
h
@ursus it isn't native, but constructor injection
So should apply as well, but I get the need for a more specific example
u
I mean, if a library module should include graph class like NetworkingGraph in :networking, or it this :app responsibilty to create the NetworkingGraph class and wire up NetworkingFoo (from :networking) in it
196 Views