Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @IntoSet for superclass #368

Open
rnett opened this issue Mar 19, 2024 · 1 comment
Open

Support @IntoSet for superclass #368

rnett opened this issue Mar 19, 2024 · 1 comment

Comments

@rnett
Copy link

rnett commented Mar 19, 2024

I have something that looks like

interface LifecycleListener {
  fun load() {}
}

interface EntityService {
  fun getEntities(): List<Entity>
}

class DefaultEntityService : EntityService, LifecycleListener  {
  private var entities: List<Entity>? = null

  override fun load() {
    entities = loadEntities() // not shown
  }

  override fun getEntities() {
    return entities
  }

}

to bind this properly, I need to do

interface EntityComponent {
  @get:Provides
  val entityService: EntityService = DefaultEntityService()
  @get:IntoSet
  val DefaultEntityService.bind: LifecycleListener = this
}

which gets even worse when you add scopes.

I would like to be able to do

interface EntityComponent {
  @get:Provides
  @get:IntoSet(LifecycleListener::class)
  val entityService: EntityService = DefaultEntityService()
}
@rnett
Copy link
Author

rnett commented Mar 19, 2024

You could support multiple IntoSet annotations on the same binding, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant