MVVM Architecture, ViewModel, MutableLiveData and LiveData
MVVM Architecture MVVM is one of the architectural patterns which enhances separation of concerns, it allows separating the user interface logic from the business (or the back-end) logic. Its target (with other MVC patterns goal) is to achieve the following principle “Keeping UI code simple and free of app logic in order to make it easier to manage”. MVVM has mainly the following layers: Model Model represents the data and business logic of the app. One of the recommended implementation strategies of this layer, is to expose its data through observables to be decoupled completely from ViewModel or any other observer/consumer. All the UI logic should be implemented in View Model. For example, when the data is fetching, a progress bar is shown, after the data is loaded, the progress bar is dismissed, and the UI is updated. The interaction of UI logic is done in View Model, because View Model is holding all the properties that binding to the View. All the view change ...