Let's say the app performs a simple read operation on the RTDB, maybe something like this:
Firebase.database.reference.child("foo").addListenerForSingleValueEvent (object: ValueEventListener {
override fun onCancelled(p0: DatabaseError) = Unit
override onDataChange(snap: DataSnapshot) {
//....
}
})
Let's say the connection has not been established, maybe because the user is not connected to the Internet, to begin with, or they lost the connection, and a read is initiated from a Fragment
, so unless the user reconnects to the Internet and the read succeeds or they restart the app and the read request is removed (in the case where offline persistence is disabled), the read request will remain and the app will try to connect to the Firebase RTDB to fetch the data.
So my question here is, is there a way to "cancel" a read request after a certain amount of time passes, maybe by using the delay
coroutine and after a certain delay period, "canceling" the read request, and initiating it again only after notifying the user to check their connection or something similar.