You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The API documentation for Flow<T>.timeout suggests using a catch{} without rethrowing:
flow {
emit(1)
delay(100)
emit(2)
delay(100)
emit(3)
delay(1000)
emit(4)
}.timeout(100.milliseconds).catch {
emit(-1) // Item to emit on timeout
}.onEach {
delay(300) // This will not cause a timeout
}
This will emit -1 for any and all upstream exceptions (admittedly none other possible in this fizz buzz example). Can we update the documentation to be more targeted?
Such as this.
flow {
emit(1)
delay(100)
emit(2)
delay(100)
emit(3)
delay(1000)
emit(4)
}.timeout(100.milliseconds).catch { exception ->
if (exception is TimeoutCancellationException) {
// Catch the TimeoutCancellationException emitted above.
emit(-1) // Item to emit on timeout
} else {
throw exception
}
}.onEach {
delay(300) // This will not cause a timeout
}
The text was updated successfully, but these errors were encountered:
The API documentation for
Flow<T>.timeout
suggests using acatch{}
without rethrowing:This will emit -1 for any and all upstream exceptions (admittedly none other possible in this fizz buzz example). Can we update the documentation to be more targeted?
Such as this.
The text was updated successfully, but these errors were encountered: