Marc Plano-Lesay
04/28/2021, 4:26 AMAppComponent
that's a singleton, holding a few singletons, including a TaskRegistry
• A TaskSubComponent
, scoped to a TaskScope
, declared through Anvil with @MergeSubcomponent(TaskScope::class)
, which I think might be a mistake. A few classes are bound to this scope through @TaskScoped
(the Dagger/javax.inject annotation) and @ContributesBinding(TaskScope::class
Now in my TaskRegistry
, I'm trying to instantiate tasks (which have a bunch of dependencies, all bound to TaskScope
). The way I'm trying to do this is by injecting in my TaskRegistry
a Provider<TaskSubComponent>
, and using this to instantiate new tasks. In my AppComponent
, I'm declaring my sub-component as well (fun taskSubComponent(): TaskSubComponent
).
At build-time, Dagger complains that it can't provide the sub-component as it doesn't have a binding. I thought that's what @MergeSubcomponent
was basically achieving, but I'm clearly misunderstanding it. What I'm doing seems to be quite close to the LoggedInScope
in the sample, but it doesn't seem to be used anywhere so I'm not really sure what's going on there...
Does anyone have any hint/documentation other than the readme?ralf
04/28/2021, 4:46 AMMarc Plano-Lesay
04/28/2021, 4:48 AMralf
04/28/2021, 4:50 AMMarc Plano-Lesay
04/28/2021, 4:55 AMMarc Plano-Lesay
04/28/2021, 4:56 AMMarc Plano-Lesay
04/28/2021, 5:49 AMralf
04/28/2021, 3:36 PMProvider<TaskSubComponent>
. You can’t do that. To create a subcomponent you grab the parent component and then call the factory method fun taskSubComponent(): TaskSubComponent
. You can’t inject a subcomponent.Marc Plano-Lesay
04/28/2021, 9:23 PMTaskSubComponent.Factory
- I guess it's semantically equivalent?