Open ash995 opened 6 years ago
Hi @ash995 , thank you for being interested in this project. If LiveData is utilized, RxJava should be removed. About ViewModel, it is a good idea and I'm considering about it.
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. I agree with what you pointed out, but it just seems that you are mixing up several architectures here. This project leverages MVP architecture. LiveData is made to work well with MVVM which Google leverages, and UseCase/Interactor are parts of Clean Architecture that I created a separate example here.
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.