- you can use the LiveData in background thread safely
- you can use the LiveData out of ViewModel without considering memory leak(except observeForever)
dependencies
allprojects {
repositories {
//...
maven { url 'https://www.jitpack.io' }
}
} dependencies {
def lastSafeLiveDataVersion = "1.1.1" //replace lastSafeLiveDataVersion
implementation "com.github.dqh147258:SafeLiveData:$lastSafeLiveDataVersion"
}use it by
val infoLiveData = SafeLiveData<Int>()or
val yourLiveData = MediatorLiveData<Int>()
val infoLiveData = SafeLiveData<Int>(yourLiveData)