Skip to content

Explore graph reducers #171

Description

@ZacSweers

An idea from @swankjesse.

Part 1

If we have an assisted class like so

@Inject
class LoginScreen(
  apiService: ApiService, // injected
  @Assisted token: UserToken
) {

  @AssistedFactory
  interface Factory {
    fun create(token: UserToken): LoginScreen
  }
}

It should be possible expose a function of the same matching parameter + return type signature on the dependency graph

@DependencyGraph
interface AppGraph {
  fun createLoginScreen(token: String): LoginScreen
}

Part 2

We could also combine this with @GraphExtensions. These are factories of their own, so we could ostensibly reduce further. For example if a LoginScreen only exists in the extension, we could chain those assisted parameters all the way down

@DependencyGraph
interface AppGraph {
  fun createLoginScreen(token: UserToken): LoginScreen

  fun createLoggedInGraph(token: UserToken): LoggedInGraph
}

@GraphExtension
interface LoggedInGraph {
  fun createLoginScreen(token: UserToken): LoginScreen
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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