chinwag-android/app/src/main/java/com/keylesspalace/tusky/util/RxAwareViewModel.kt

19 lines
478 B
Kotlin
Raw Normal View History

2019-12-31 23:57:24 +11:00
package com.keylesspalace.tusky.util
import androidx.annotation.CallSuper
2019-12-31 23:57:24 +11:00
import androidx.lifecycle.ViewModel
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.disposables.Disposable
2019-12-31 23:57:24 +11:00
open class RxAwareViewModel : ViewModel() {
val disposables = CompositeDisposable()
fun Disposable.autoDispose() = disposables.add(this)
@CallSuper
2019-12-31 23:57:24 +11:00
override fun onCleared() {
super.onCleared()
disposables.clear()
}
}