2019-12-31 23:57:24 +11:00
|
|
|
package com.keylesspalace.tusky.util
|
|
|
|
|
2021-01-22 04:57:09 +11:00
|
|
|
import androidx.annotation.CallSuper
|
2019-12-31 23:57:24 +11:00
|
|
|
import androidx.lifecycle.ViewModel
|
2021-05-17 03:53:27 +10:00
|
|
|
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)
|
|
|
|
|
2021-01-22 04:57:09 +11:00
|
|
|
@CallSuper
|
2019-12-31 23:57:24 +11:00
|
|
|
override fun onCleared() {
|
|
|
|
super.onCleared()
|
|
|
|
disposables.clear()
|
|
|
|
}
|
2021-06-29 05:13:24 +10:00
|
|
|
}
|