SingleResult
A Single that completes with a TealiumResult.
With a SingleResult you can subscribe as any other type of Single, but you can also subscribe only for onSuccess or onFailure to receive the event only in case the event is respectively either a success or a failure.
So in case you want to handle both success and failure:
single.subscribe { result ->
try {
val value = result.getOrThrow()
// handle success
} catch (ex: Exception) {
// handle ex
}
}Content copied to clipboard
In case you want to handle only successes:
single.onSuccess { value ->
// Handle success
}Content copied to clipboard
In case you want to handle only failures:
single.onFailure { exception ->
// Handle failure
}Content copied to clipboard