0leg
0leg

Reputation: 14154

Android's ViewModel and MVVM

There is a design pattern called MVVM (Model-View-View Model), in which a View Model is used as an abstraction of a View. The View Model supposed to expose streams of data to the View and interact with Model's data.

However there is a ViewModel class in Android's framework.


Question: does Android's ViewModel have something to do with the View Model from MVVM pattern?

Upvotes: 5

Views: 627

Answers (1)

Adam
Adam

Reputation: 16199

They are different. The ViewModel that Android is referring to is just.

The ViewModel class is designed to store and manage UI-related data so that the data survives configuration changes such as screen rotations.

The MVVM pattern will require a View, ViewModel and Model. With binding occurring between the View and ViewModel.

The Android ViewModel interacts with the UIController, and is almost just a state hold for UI, rather than following the MVVM pattern.

Upvotes: 1

Related Questions