Android Architecture Patterns Part 2: Model-View-Presenter
Florina Muntenescu
1.3K9

Hi Florina Muntenescu. Thank you for this article. I have a question regarding the MVP design pattern. Lets say if I want to initiate a component of the app and the view for that component has been initiated using the Fragment. Now, this fragment has some arguments passed when I get an instance for this fragment usingFragment.newInstance(String param1) . Now this parameter needs to be passed to the Presenter layer as this parameter is being used by the Repository to get the relevant data. How do I handle the subscribe() and unsubscribe() method calls when the fragment resumes and pauses, respectively. I do not have param1 here. There are two options that I see here. First, is to have this parameter passed while initiating the presenter or second is to have it passed in the subscribe() method of the presented. Or the initializing of the fragment with a parameter in itself is conceptually incorrect?