Without using FragmentFactory
, scoping dependencies within Fragment is straigth forward. Just create a Subcomponent
for your fragment and just create the Fragment
's Subcomponent in onAttach()
.
But when using FragmentFactory
you no longer inject dependencies via the subcomponent but instead pass then in Fragment
's constructor.
I was wondering if I could still declare a dependency which should only last within the fragment's lifecycle using Dagger
. I currently could not think of a way to achieve this.
So instead of binding my dependencies to a certain scope, I just declare the dependency with any scope or just use @Reusable
on them.
Also, since fragments are created through FragmentFactory
, the created Fragments
doesn't exist in the DI graph.
How can we properly scope dependencies to fragment and also be able to add the fragment in the DI graph when using FragmentFactory
?