Skip to content

Investigate supporting implicit GraphExtension factory functions #1892

@ZacSweers

Description

@ZacSweers

Description

Originally mentioned in #1872, it turns out dagger allows declaring a subcomponent accessor function with parameters and effectively becomes a factory. This is similar to #171 but specific to just extensions.

If we support this for interop, we may not want to support it without interop as I'm not sure this is really preferable to an explicit (and single) factory.

@DependencyGraph
interface ParentGraph : ChildGraphProvider {
  fun createChild(@Provides input: String): ChildGraph
}

@GraphExtension
interface ChildGraph {
  // No factory defined here
}

Alternatives/workarounds

Use a traditional GraphExtension.Factory

@DependencyGraph
interface ParentGraph : ChildGraph.Factory {
  
}

@GraphExtension
interface ChildGraph {
  // Define a factory
  @GraphExtension.Factory
  interface Factory {
    fun createChild(@Provides input: String): ChildGraph
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestinteropAnything pertaining to interop

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions