erikjhordan-rey / People-MVVM

Sample created to practice MVVM and DataBinding in Android Applications.
https://erikjhordan-rey.github.io/blog/2015/12/15/ANDROID-databinding-android.html
667 stars 193 forks source link

PeopleViewModel has reference to View #2

Closed lonja closed 7 years ago

lonja commented 8 years ago

maybe PeopleViewModel should has reference to PeopleAdapter instead View?

erikjhordan-rey commented 8 years ago

@lonja I can't understand your comment, Could you more explicit please? but if you are looking the View Model for adapter you can see this https://github.com/erikcaffrey/People-MVVM/blob/master/app/src/main/java/com/example/jhordan/people_mvvm/viewmodel/ItemPeopleViewModel.java

ghost commented 8 years ago

Hi, I think @lonja mean that you pass view contract to viewmodel and now it look more like presenter than viewmodel.

And i also want to resolve this issue (communicating with activity from viewmodel) but not know how. Maibe @lonja know?

abiemann commented 7 years ago

I'm not impressed by class PeopleActivity extends AppCompatActivity implements PeopleViewModelContract.MainView because PeopleViewModelContract.MainView feels more like MVP. For MVVM I anticipated an observer to make the adapter watch the list of data

erikjhordan-rey commented 7 years ago

@abiemann It was my first iteration I'm according with you communication isn't Model ViewModel but neither MVP, it's a Presentation Model pulls the state and behavior of the view out into a model class that is part of the presentation. The Presentation Model coordinates with the domain layer and provides an interface to the view that minimizes decision making in the view. I created a new implementation more like MVVM Solution -> https://github.com/erikcaffrey/People-MVVM/pull/7 although for me the best solution is to use a DataBinding Engine. Thanks for your feedback!