I have implemented MVP pattern in my application.
I have an additional layer which I call Repository, which is responsible for running HTTP asynchronous requests. I have created OnTaskCompleteListener interface for communication between Repository and Model (Model implements OnTaskCompleteListener). So when Repository finishes the request, it calls a method in Model and updates data. Then, Model calls a method in Presenter with the same mechanism, to let it know that Model has been updated.
What I am worrying, is the chain of callbacks that comes from Repository up to Presenter.
Is there a better way to communicate between components of MVP or is it the way to go?
I did try "EventBus", but a large number of needed interfaces scared me off.
Observer did not seem fit as there is only one listener for each component (Model listens to Repository, Presenter listens to Model).
Thank you.
Android: MVP. Right way to communicaticate between components
1k Views Asked by Sermilion At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in ANDROID
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in DESIGN-PATTERNS
- Pass Data between two view controllers using 'Delegation' : Objective-C
- Revealing module pattern instantiation and naming convention
- Is using the same Redis instance for different applications against Separation of Concerns principle?
- Swift - Issue trying to access to Singleton object
- How to set data context of ViewModela View's xaml?
- How to use nested builder pattern in json?
- Is object casting a good practice?
- reference data class member visitor pattern
- variable global const "macros" in C++ and optimal design patterns
- How to design abstract listener and its implementation?
- DTOs with different granularity
- Object creation depending on caller
- What is the proper way to use inheritance when combined with factory method?
- Is this Java Enumeration Used/Designed Correctly?
- Design pattern for incremental code
Related Questions in CALLBACK
- Change setInterval value dynamically
- Pass Data between two view controllers using 'Delegation' : Objective-C
- I'm trying to make the "merge function" work by writing a Callback.
- Can ajaxSetup.success callback prevent ajax.complete callback from being called?
- Passing a callback function in options object to other function
- Nested asynchronous calls using AngularJS
- callback google play on installed app
- Defining Callbacks for custom Javascript Functions
- Passing function name as callback doesn't work as expected in my class
- What is the purpose of javax.security.auth.callback.*?
- Querying DynamoDB with Lambda does nothing
- Android version of NSNotificationCenter (event binding)
- async js callback for each upload
- Does django server support url callbacks (webhooks)?
- How to update label from callback function in code behind?
Related Questions in MVP
- How to apply MVP pattern to android project
- Searching for an example of class-binding by a interface
- MVP in WinForms ( presenter & program.cs)
- Maintaining different build flavors across modules in Android Studio
- Can I create View and Presenter in different Project in MVP Pattern
- Android MVP communications
- Android: MVP. Right way to communicaticate between components
- MVP, set the view of the presenter to null on destroy?
- MVP for android. Is it worth the effort?
- Dagger 2 multiple Retrofit instances built with different URLs for hitting different APIs using constructor injection
- Android : best case for communicating adapter with Activity/Fragment
- How to data-bind my View's button to the Model, via its interface in the Presenter
- How to test second activity started in instrumentation test in MVP?
- Android. Interact with menu from Presenter
- Android MVP architecture - communication between repository and view
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
After extensive reading, I came to a conclusion, that I do not need another class 'Repository' to delegate loading of data. The model actually should be responsible for loading and holding data. Using a callback method parameter for the method of the presenter, that calls a method that loads data in the model is a great way to communicate between model and presenter.
Presenter.java
This way model, presenter and view are linked in this single method in very clear and intuitive manner. Hope this will help someone.