I've created a portion of code that call firebase database in order to fetch data. this data is used below to do other things. the problem is the code under the call is run before the data is fetched. is there a way to run it in sequence ?
Asked
Active
Viewed 23 times
1 Answers
1
Data is loaded from Firebase asynchronously. Any code that requires the data must be called from within the onDataChange
(for Realtime Database) or onComplete
/onEvent
(for Firestore) listeners.
For some good examples of how to do this, see:
- Realtime Database: getContactsFromFirebase() method return an empty list
- Firestore: How to check a certain data already exists in firestore or not

Frank van Puffelen
- 565,676
- 79
- 828
- 807