I see that if one instantiates a Dagger 2 Component in an Activity, then it's later nulled in the onDestroy()
method like seen here.
public class MyActivity {
private MyActivityComponent component;
//...
public void onCreate() {
component = Dagger_MyActivityComponent.builder()
.myApplicationComponent(App.getComponent())
.build()
.inject(this);
//...
}
public void onDestroy() {
component = null;
}
}
What happens if I don't null
that instance and what would happen?
Side note: in comments I've found useful hint why one would set it to null
which is pretty convincing: "I don't think it's necessary but it defines scope pretty clear".