This sample is based on the todo-mvp and combined other two samples, one is the todo-datatbinding and onther is todo-mvp-rxjava. Using the Data Binding library to display data and bind UI elements to actions and through the RxJava to communicate between the data model and presenter layer.
This sample doesn't follow a strict Model-View-ViewModel or a Model-View-Presenter pattern, as it uses both View Models and Presenters.
The responsibility of each component in this sample is:
- Activity: Object creation.
- Fragment: Interaction with framework components.
- Presenter: Receives user actions and retrieves the data from the repository.
- ViewModel: Exposes data for a view.
Using RxJava streams as a way of retrieving task. The RxJava provides the easy way to convert between threads.
Developers need to be familiar with RxJava and Data binding.
Very high. Unit tests are easy to implement, because the Observable of RxJava is highly unit testable.
Similar with TODO-MVP.
Compared to TODO-MVP, each page add ViewModel class but less UI code per Activity and Fragment, and add some classes to encapsulate the Schedulers of RxJava.
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Java 54 1459 1554 3734 (3450 in MVP)
XML 35 126 337 734
-------------------------------------------------------------------------------
SUM: 89 1585 1891 4468
-------------------------------------------------------------------------------
Easier than MVP for small changes. A new feature might require some experience with RxJava and Data Binding library.
The Data Binding library takes care of the communication between some components, so developers need to understand what it does and doesn't before making changes to the code.
The RxJava uses new concepts, so developers need to understand how it work.