https://kotlinlang.org logo
#feed
Title
# feed
m

marcinmoskala

02/26/2018, 7:55 AM
Dependency Injection: the pattern without the framework by @jmfayard https://blog.kotlin-academy.com/dependency-injection-the-pattern-without-the-framework-33cfa9d5f312
👌 2
r

rawtoast

02/26/2018, 10:41 AM
IDK much about the Android specifics, but it’s always nice to see the articles on framework-less DI.
c

cedric

02/26/2018, 10:09 PM
If only to realize that framework-full DI is pretty darn useful 🙂
r

rawtoast

02/27/2018, 9:44 AM
Meh, I only seem to use DI frameworks when forced to 😛
c

cedric

02/27/2018, 5:49 PM
I have yet to see a convincing DI native approach that offers something even remotely similar to modules (which are a very important part of an effective DI solution).
d

deviant

02/28/2018, 9:10 AM
after using gorgeous spring di i can't look on other "lightweight" di frameworks without tears (hello dagger2)
t

trathschlag

02/28/2018, 12:03 PM
This is my kotlin dependency injection framework:
Copy code
abstract class InjectionModule {
    fun <T : Any> singleton(provider: () -> T) = lazy(provider)
    
    fun <T : Any> provide(provider: () -> T) = TransientProviderProperty(provider)
}

class TransientProviderProperty<out T : Any>(private val _provider: () -> T) {
    operator fun getValue(thisRef: Any?, property: KProperty<*>) = _provider()
}
c

cedric

02/28/2018, 6:50 PM
@deviant Interesting, to me it’s Spring DI that looks bloated and inconvenient, while Dagger 2 is lean and more statically typed too
6 Views