标签 mvvm 下的文章

LiveData+ViewModel+Repository搭建MVVM

什么是LiveData

LiveData is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state.
Source:https://developer.android.com/topic/libraries/architecture/livedata.html

什么是ViewModel

The ViewModel class is designed to store and manage UI-related data in a lifecycle conscious way. The ViewModel class allows data to survive configuration changes such as screen rotations.
Source:https://developer.android.com/topic/libraries/architecture/viewmodel

ViewModel的生命周期

ViewModel的生命周期

- 阅读剩余部分 -