-
Notifications
You must be signed in to change notification settings - Fork 8
Bind to the Fragment
Valery edited this page Aug 8, 2019
·
4 revisions
Bind the component to the Fragment is the same as bind the component to the Activity class.
- Implement the IHasComponent interface;
- Override the getComponent method;
- Override the getComponentKey method (if needed);
- Bind the component to the fragment.
class FragmentA : Fragment(), IHasComponent {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
XInjectionManager.instance
.bindComponent<FeatureAComponent>(this)
.inject(this)
}
override fun getComponent(): FeatureAComponent =
DaggerFeatureAComponent.builder().build()
}