How to await for firestore database to fetch data before returning it
So I am using firestore database and need to fetch some data from it. How do I make the function await for the data before returning the list?
fun getExercise(bodyPart: String): MutableList {
val db = Firebase.firestore
val exercisesList = mutableListOf()
val exercise = db.collection("exercises")
val query = exercise.whereEqualTo("body-part", bodyPart)
query.get().addOnSuccessListener { result ->
for(temp in result) {...