I using the firebase firestore to query information to load into a UI fragment. I could easily do. This call in the fragment and set the view data in the on complete listener callback. However, I don't want my view classes doing any database and network calls. The problem with doing it from a separate class is that the query call is asynchronous so I can't immediately pass the data until the listener is invoked.
Hopefully that makes sense.
Not the Firestore query is asynchronous, onSuccess
and onComplete
methods have an asynchronous behaviour.
So you can solve ths issue, using my answer from this post. So you can call readData()
method from within the same class or if needed, from another class.