Suppose we have two components in different scope with different lifetime. In one, there are purely activity-specific things (SharedPreferences, all sorts of system managers that depend on Context), in the other, session information (current user, token, session ID, etc.), i.e. pure business info without reference to Android and context.
Scopes live different lives, one can be created earlier than the other and vice versa, it cannot be made into subcomponents for each other.
And here, for example, a presenter appears, in which you need to transfer dependencies from these two components. That both components will be ready for this moment, I can guarantee it. What are the options for injecting? It is impossible to make the third subcomponent, the skoups are different, Dagger swears (even if the skoups have no common parent). List dependencies in the constructor of a presenter with hands without annotations Inject?
layoutInflater = Injector.getViewComponent().getLayoutInflater(); currentSessionId = Injector.getSessionComponent().getSessionId(); It turns out quite verbose. Divide the dependencies into two sets and put them in separate classes inside the presenter?
public class Presenter { public static class SessionPart { @Inject protected String currentSessionId; public SessionPart() { Injector.getSessionComponent().inject(this); } } public static class ViewPart { @Inject protected LayoutInflater layoutInflater; public ViewPart() { Injector.getViewComponent().inject(this); } } public Presenter() { s = new SessionPart(); v = new ViewPart(); } } Also a lot of writings. Or are there other ways? Or is the approach so completely wrong, and the components need to be designed differently?
Here it seems to be asking about the same thing, while no response.