Replace subscribe with subscribeBy

This commit is contained in:
Bart Sopers 2021-02-28 15:45:50 +01:00
parent 5c8ba98682
commit 513ac9b0f4

View file

@ -7,6 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.rxkotlin.subscribeBy
abstract class ActionViewModelBase( abstract class ActionViewModelBase(
protected val injector: HasAndroidInjector, protected val injector: HasAndroidInjector,
@ -21,10 +22,12 @@ abstract class ActionViewModelBase(
fun executeAction() { fun executeAction() {
_isActionExecutingLiveData.postValue(true) _isActionExecutingLiveData.postValue(true)
val disposable = doExecuteAction().subscribe({ result -> val disposable = doExecuteAction().subscribeBy(
onSuccess = { result ->
_isActionExecutingLiveData.postValue(false) _isActionExecutingLiveData.postValue(false)
_actionResultLiveData.postValue(result) _actionResultLiveData.postValue(result)
}, { throwable -> },
onError = { throwable ->
logger.error(LTag.PUMP, "Caught exception in while executing action in ActionViewModelBase", throwable) logger.error(LTag.PUMP, "Caught exception in while executing action in ActionViewModelBase", throwable)
_isActionExecutingLiveData.postValue(false) _isActionExecutingLiveData.postValue(false)
_actionResultLiveData.postValue(PumpEnactResult(injector).success(false).comment(throwable.message)) _actionResultLiveData.postValue(PumpEnactResult(injector).success(false).comment(throwable.message))