MVVM-5: Views should always know about changes after ViewModels, no matter how trivial an operation may be.


Description

Adhering to this guideline implies that all the logic in the Views should be moved to the ViewModels. While the purpose of ViewModels is to pre-process data to be ready to use by Views, it might be tempting to implement minor operations in Views. Nevertheless, adhering to this guideline guarantees a higher level of consistency and reliability of all the components which are based on the ViewModels.

Example

We created a simple MVVM example.

Our viewModel provides all the data for the View. When a new note is added to the model, the list of notes has been changed, and a new stream from the model to the viewModel is passed. The View observes this changed list and updates the view.

Check this page to view the complete repository.