https://kotlinlang.org logo
#android
Title
# android
d

Denys

05/25/2020, 7:55 AM
Hello everyone. I use the Room as database in my app. In my DAO, I use Flow as the return type so that the user interface updates automatically when the underlying data changes. The problem is that if an error occurs and I process it with the catch operator, I will never receive an update again in Flow. I don’t know how I can keep an active subscription to the database in case of an error. I would be grateful for any advice
g

gildor

05/25/2020, 12:48 PM
Why do you receive error from database? It's not what I would expect from db observer Error is terminal operator, it's the same as complete, no events will happen after that, flow is cancelled, even if catch error. But you can subscribe again collect flow. There is operator
retry
which can do this for you: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/retry.html
3 Views