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.
CodePudding user response:
You can simply check for the snapshot
object if it's null then there is no data at that particular reference node like this:
anyRef.get().addOnSuccessListener(snapshot -> {
if (snapshot != null) {
// data exists
} else {
// data doesn't exist
}
}