Introduction
A ViewModel helps keep your app data safe when the screen changes or rotates. It holds data for the screen and keeps it alive.
When you want to keep user data safe during screen rotation.
When you need to share data between different parts of the app screen.
When you want to separate data logic from the screen design.
When you want to avoid losing data after temporary app pauses.
When you want to make your app easier to test and maintain.