iamanbansal
iamanbansal

Reputation: 2752

Use ViewModel in case other than Rotation

For what other purposes we can use ViewModel for?

I have been asked if an Activity is locked to portrait mode, then is this relevant to use ViewModel? If Yes why?

Upvotes: 1

Views: 55

Answers (1)

Onik
Onik

Reputation: 19959

In general, ViewModel is an architectural component that "couples" a view with a model. From the architectural point of view it is relevant.

Additionally to the general component, Android Jetpack's ViewModel is also lifecycle-aware. You can treat it as a conveniency bonus.

With that being said, if the app is not supposed to have configuration changes (screen rotation is one of those) you may use any CustomViewModel.

Upvotes: 1

Related Questions