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

Multiple scopes support #565

Open
steelahhh opened this issue Jan 26, 2023 · 0 comments
Open

Multiple scopes support #565

steelahhh opened this issue Jan 26, 2023 · 0 comments

Comments

@steelahhh
Copy link

I've got a project with Anvil + Tangle integrated, and now I've got the need to introduce several Subomponents (essentially LoggedIn/LoggedOut) to scope some dependencies

This is the Subcomponent definition

abstract class UserScope private constructor()

@ContributesSubcomponent(scope = UserScope::class, parentScope = AppScope::class)
interface UserComponent {
  @ContributesSubcomponent.Factory
  interface Factory {
    fun create(): UserComponent
  }

  @ContributesTo(AppScope::class)
  interface ParentComponent {
    fun createActivitySubcomponent(): Factory
  }
}

Adding this to the sample project, results in this stacktrace:

/[redacted]/Tangle/sample/app/build/tmp/kapt3/stubs/debug/tangle/sample/app/AppComponent.java:9: error: [Dagger/DuplicateBindings] @tangle.fragment.TangleFragmentProviderMap tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.BreedDetailFragment is bound multiple times:
public abstract interface AppComponent extends tangle.inject.AppScope_TangleInjectorComponent, tangle.inject.AppScope_TangleScopeMapProviderComponent, tangle.sample.app.AppScope_Tangle_Worker_Component, tangle.sample.app.AppScope_Tangle_ViewModel_Component, tangle.sample.ui.UserComponent.ParentComponent, anvil.component.tangle.sample.app.appcomponent.UserComponentA.ParentComponent {
                ^
      @Provides @tangle.fragment.TangleFragmentProviderMap @org.jetbrains.annotations.NotNull tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.BreedDetailFragment tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.Tangle_AppScope_Fragment_Module.Companion.provide_BreedDetailFragment(dispatch.core.MainImmediateCoroutineScope)
      @Provides @tangle.fragment.TangleFragmentProviderMap @org.jetbrains.annotations.NotNull tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.BreedDetailFragment tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.Tangle_UserScope_Fragment_Module.Companion.provide_BreedDetailFragment(dispatch.core.MainImmediateCoroutineScope)
      @tangle.fragment.TangleFragmentProviderMap tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.BreedDetailFragment is injected at
          tangle.sample.ui.fragmentsWithManualNavigation.breedDetail.Tangle_UserScope_Fragment_Module.bind_BreedDetailFragment(fragment)
      @tangle.fragment.TangleFragmentProviderMap java.util.Map<java.lang.Class<? extends androidx.fragment.app.Fragment>,javax.inject.Provider<androidx.fragment.app.Fragment>> is injected at
          tangle.fragment.AppScope_Tangle_FragmentFactory_Module.Companion.provide_TangleFragmentFactory(…, tangleProviderMap)
      tangle.fragment.TangleFragmentFactory is injected at
          tangle.sample.ui.fragmentsWithArchNavigation.FragmentsArchNavigationMainActivity.tangleFragmentFactory
      dagger.MembersInjector<tangle.sample.ui.fragmentsWithArchNavigation.FragmentsArchNavigationMainActivity> is injected at
          tangle.sample.ui.fragmentsWithArchNavigation.Tangle_FragmentsArchNavigationMainActivityInjector(injector)
      tangle.sample.ui.fragmentsWithArchNavigation.Tangle_FragmentsArchNavigationMainActivityInjector is injected at
          tangle.sample.ui.fragmentsWithArchNavigation.AppScope_Tangle_FragmentsArchNavigationMainActivityInjector_Module.multibindTangle_FragmentsArchNavigationMainActivityInjectorIntoMap(injector)
      java.util.Map<java.lang.Class<?>,javax.inject.Provider<tangle.inject.internal.TangleInjector<?>>> is requested at
          tangle.inject.internal.TangleInjectorComponent.getInjectors() [tangle.sample.app.AppComponent → anvil.component.tangle.sample.app.appcomponent.UserComponentA]

Any workarounds or is this something that Tangle does not support?

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