In Android, MVC refers to the default pattern where an Activity acts as a controller and XML files are views. MVVM treats both Activity classes and XML files as views, and ViewModel classes are where you write your business logic. It completely separates an app’s UI from its logic.
What is MVVM Architecture in Android?
The main players in the MVVM pattern are: The View — that informs the ViewModel about the user’s actions. The ViewModel — exposes streams of data relevant to the View. The DataModel — abstracts the data source. The ViewModel works with the DataModel to get and save the data.
How use MVVM pattern in Android?
There are two ways to implement MVVM in Android: Data Binding. RXJava.
…
How is it possible to notify some class without having a reference of it?
- Using Two Way Data Binding.
- Using Live Data.
- Using RxJava.