Issue
I am trying to implement a clean way of notifying my UI that there is no data. It's more like a listener that check that there is network connection but no data at that location. How do I do this? I have tried 998 ways :(, they all work but the complexity of implementing them in every class that listens for data is giving me nausea. Thanks for your reply.
Solution
You can simply check for the snapshot
object whether there is data at that particular reference node or not like this:
anyRef.get().addOnSuccessListener(snapshot -> {
if (snapshot.exists()) {
// data exists
} else {
// data doesn't exist
}
}
Answered By - UndefinedBug1.0
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.