0

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.

Levi Moreira
  • 11,917
  • 4
  • 32
  • 46
Jerum
  • 71
  • 2
  • 9

2 Answers2

1

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.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
0

You can use mvp pattern. it will allow to write load functions not in the Fragment class. The speed of loading directly depends on your network connection speed.

Rob
  • 886
  • 9
  • 16
  • Well the problem is if I call from a presenter I'll get a null method return. This is because the firebase query is asynchronous – Jerum Apr 20 '18 at 22:22