Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 1.12 KB

README.md

File metadata and controls

25 lines (17 loc) · 1.12 KB

ViewModel in kotlin

This project explains with a simple example of how to implement the view model in kotlin

  • ViewModel handles all the data for the UI
  • it is created when an activity is created. It survives configuration changes.
  • when using ViewModel and suppose configuration changes or you switch apps, old data will remain saved in ViewModel
  • It is destroyed only when activity is destroyed or when you press the back button and the application is closed and activity is destroyed.

lifecycle of a ViewModel

ViewModel lifecycle

App Screenshots

potrait landscape

References