evant / kotlin-inject

Dependency injection lib for kotlin
Apache License 2.0
1.24k stars 55 forks source link

Ability to bind Implementaion with Interface #336

Closed georgeci closed 10 months ago

georgeci commented 10 months ago

As I understand it now, it looks like this

interface SplashComponent

@Inject
class DefaultSplashComponent() : SplashComponent

@Component
abstract class SplashDiComponent {
    @Provides
    fun bind(component: DefaultSplashComponent): SplashComponent = component
}

This is a very popular use case and It would be nice to be less verbose. Like this.

interface SplashComponent

@BindAs(SplashComponent::class)
@Inject
class DefaultSplashComponent() : SplashComponent
evant commented 10 months ago

this looks the same as https://github.com/evant/kotlin-inject/issues/212