Reputation: 1253
What is the use of @Subcomponent
in our application?
@Subcomponent
interface PostActivitySubComponent : AndroidInjector<PostsActivity> {
@Subcomponent.Builder
abstract class Builder : AndroidInjector.Builder<PostsActivity>()
}
The application works fine with and without this component. What is the purpose of this?
Upvotes: 0
Views: 119
Reputation: 195
@SubComponent
is very helpful for the large application where Activities/Fragments where you provide dependencies for the specefic screen. For example you have AppComponent
and SubComponent
named ProfileDetailedComponent
and you have no posssibility to control memory , but SubComponent
help to you control memory with @Scope
. For the each screen you will create SubComponent
and SubComponent
annotated all provides with @CustomScope
and when user leave current screen , you can clear current component and free up memory , in the onDestroy()
method. In sum @SubComponent
need to contol your application memory.
Upvotes: 1