oday
08/15/2022, 6:47 PMif (marketingConsentTypes != null && marketingConsentTypes.all { it in validEnumValues }) {
viewModelScope.launch(coroutineDispatchers.main) {
marketingConsentTypes.forEach { consentType ->
giveConsent.execute(
GiveConsent.Input(
consentType = GiveConsent.ConsentType.valueOf(consentType),
hasGivenConsent = true
)
).await()
}
isLoading.postValue(false)
}
} else {
error.postValue(Event(Throwable()))
}
the issue is not that I am running this usecase in a loop, that’s what I want
the issue is that I would like to get back the Throwable that this usecase already does return for me, with Rx usually I’d get it back in the error block of the subscribe, here where can I get it to let my mutable property know that the error happened?oday
08/15/2022, 6:54 PMSorin
08/16/2022, 1:23 PModay
08/18/2022, 1:30 PModay
08/18/2022, 1:30 PModay
08/18/2022, 2:20 PMviewModelScope.launch(coroutineDispatchers.main) {
suspendCancellableCoroutine<GiveConsent.ConsentType> {
marketingConsentTypes.forEach { consentType ->
giveConsent.execute(
GiveConsent.Input(
consentType = GiveConsent.ConsentType.valueOf(consentType),
hasGivenConsent = true
)
).doOnError {
cancel("Message", Throwable("Exception thrown"))
}
}
isLoading.postValue(false)
addSuccessComponents()
}
}