View in the MVVM architecture
What is View in the MVVM architecture?
The View component in the MVVM architecture are the UI controllers – Activities and Fragments. They should be as free as possible from any business logic. Their role is to present the data, not to transform it. The view should contain only UI related logic. It is a common misconception to write all the logic for a particular screen in the corresponding Activity or Fragment. By doing so, we create God classes and we break the single responsibility principle. So we should always try to keep our View as clean as possible.
The View asks the ViewModel for data. The View doesn’t care where the data comes from, what kind of transformations are applied to it and so on. It only knows how to properly display the data on the screen. When the data is changed by user interactions with the UI components, the View calls the ViewModel’s methods and passes the changed data to them. Again, it is unaware of how the data is processed.
Letzte Beiträge
Share :
Share :
Weitere Beiträge
Missing Authorization header in Angular 7 HTTP response
Accessing an API back-end from Angular client may result in missing response headers. A common scenario is a missing Authorization header, containing the JSON Web Token (JWT) which is returned from the back-end service when the user logs in successfully.
Machine learning concepts. Data preparation
Each machine learning process related to the use of neural networks consists of at least two parts. The first part is related to data loading and preparation for training.
Repository in Android’s MVVM architecture
Repository is a class which purpose is to provide a clean API for accessing data. What that means is that the Repository can gather data from different data sources(different REST APIs, cache, local database storage) and it provides this data to the rest of the app.