-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LiveData and ViewModel implementation #4
Comments
Hi @ash995 , thank you for being interested in this project. |
Great example @quangctkm9207 just one little bit of advice; You don't need to replace RxJava with LiveData or vice-versa. LiveData should be use to communicate the ViewModel to the UI layer back and forth, while RxJava should be use as glue to hold together your UseCases/Interactors components. If you are using UseCases/Interactors to execute the business rules (let's say fetch a list of users from an API endpoint and then save it into a database cache) then these UseCases/Interactors are going to be injected with different repositories (Network Repositories using Retrofit if you are going to call the API, DB Repositories using Room, Ormlite or any other DB tech if you are going to fetch from the DB) and these repositories can be connected one with another using the RxJava methods (For example, flatMap if you want to wait for the API request to end and then save in the DB, merge if you want to return both responses merged) TL;DR You can use LiveData between the UI layer and the ViewModel/Presenter layer and RxJava beneath the UseCase/Interactor layer. |
@4gus71n : Thanks for your suggestion. |
You can have the presenter be a subclass of the ViewModel class and update data on the ui with the help of LiveData.
If you think it's a good idea I'd like to work on it.
The text was updated successfully, but these errors were encountered: