fix warning

This commit is contained in:
Andrei Vereha 2021-10-01 20:17:54 +02:00
parent 9de71e1051
commit a7f82eb4fb

View file

@ -7,12 +7,14 @@ import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import io.reactivex.Single
import io.reactivex.disposables.Disposable
import io.reactivex.rxkotlin.subscribeBy
abstract class ActionViewModelBase(
protected val injector: HasAndroidInjector,
protected val logger: AAPSLogger
) : ViewModelBase() {
private var disposable: Disposable? = null
private val _isActionExecutingLiveData = MutableLiveData(false)
val isActionExecutingLiveData: LiveData<Boolean> = _isActionExecutingLiveData
@ -22,7 +24,7 @@ abstract class ActionViewModelBase(
fun executeAction() {
_isActionExecutingLiveData.postValue(true)
val disposable = doExecuteAction().subscribeBy(
disposable = doExecuteAction().subscribeBy(
onSuccess = { result ->
_isActionExecutingLiveData.postValue(false)
_actionResultLiveData.postValue(result)
@ -35,5 +37,10 @@ abstract class ActionViewModelBase(
})
}
override fun onCleared() {
super.onCleared()
disposable?.dispose()
}
protected abstract fun doExecuteAction(): Single<PumpEnactResult>
}