Replace subscribe with subscribeBy
This commit is contained in:
parent
5c8ba98682
commit
513ac9b0f4
1 changed files with 11 additions and 8 deletions
|
@ -7,6 +7,7 @@ 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.rxkotlin.subscribeBy
|
||||
|
||||
abstract class ActionViewModelBase(
|
||||
protected val injector: HasAndroidInjector,
|
||||
|
@ -21,14 +22,16 @@ abstract class ActionViewModelBase(
|
|||
|
||||
fun executeAction() {
|
||||
_isActionExecutingLiveData.postValue(true)
|
||||
val disposable = doExecuteAction().subscribe({ result ->
|
||||
_isActionExecutingLiveData.postValue(false)
|
||||
_actionResultLiveData.postValue(result)
|
||||
}, { throwable ->
|
||||
logger.error(LTag.PUMP, "Caught exception in while executing action in ActionViewModelBase", throwable)
|
||||
_isActionExecutingLiveData.postValue(false)
|
||||
_actionResultLiveData.postValue(PumpEnactResult(injector).success(false).comment(throwable.message))
|
||||
})
|
||||
val disposable = doExecuteAction().subscribeBy(
|
||||
onSuccess = { result ->
|
||||
_isActionExecutingLiveData.postValue(false)
|
||||
_actionResultLiveData.postValue(result)
|
||||
},
|
||||
onError = { throwable ->
|
||||
logger.error(LTag.PUMP, "Caught exception in while executing action in ActionViewModelBase", throwable)
|
||||
_isActionExecutingLiveData.postValue(false)
|
||||
_actionResultLiveData.postValue(PumpEnactResult(injector).success(false).comment(throwable.message))
|
||||
})
|
||||
}
|
||||
|
||||
protected abstract fun doExecuteAction(): Single<PumpEnactResult>
|
||||
|
|
Loading…
Reference in a new issue