10
votes

I need to clear some of my doubts regarding mvp and mvvm design pattern

1) In mvp and mvvm who updates the view .The presenter/view-model set the data to be displayed in the view or the view retrieve the data from presenter/view-model and display it

2) How both presenter and view-model differ from each other. "The MVVM uses databinding to update the view whereas the presenter uses traditional methods to update the view". Is it?

1

1 Answers

11
votes

In MVP, the Presenter holds a reference to a View, usually via interfaces. When the Presenter computes new data, it is him who is responsible to call the right method on the View/Interface to update the UI.

In MVVM, the ViewModel "simply exposes" data (usually via LiveData or Rx) so it can be observed. It is not responsible for who is observing the data, and what is done with it. The view then observes that said data in the ViewModel, and updates its UI when the data changes.

To have a complete understanding of the differences between MVC, MVP and MVVM, I'd suggest to look at https://www.youtube.com/watch?v=QrbhPcbZv0I