Skip to content

Investigate simplifying contributing multiple bindings with less code #999

@ZacSweers

Description

@ZacSweers

Couple ideas

Investigate supporting @Contributes*Binding annotations on supertypes directly. Requires ensuring they're in metadata. Less sure about readability here

@Inject
class CacheImpl :
  @ContributesBinding(AppScope::class)
  Cache,
  @ContributesBinding(AppScope::class)
  AnotherType,
  @ContributesBinding(AppScope::class)
  YetAnotherType {
  override fun toString(): String = "CacheImpl"
}

Make binding vararg, perhaps as an additionalBindings vararg to match the existing scope/additionalScopes patterns.

@Inject
@ContributesBinding(
  AppScope::class,
  binding<Cache>(),
  binding<AnotherType>(),
  binding<YetAnotherType>(),
)
class CacheImpl : Cache, AnotherType, YetAnotherType

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions