Remon Shehata
05/15/2020, 1:25 AMoverride fun checkOrganization(organizationId: String): Boolean {
    var isFound = false
    db.collection(FirebaseConstants.ORGANIZATION)
        .get()
        .addOnSuccessListener { querySnapshot ->
            for (document in querySnapshot) {
                Log.d(TAG, document.id)
                if (organizationId == document.id) {
                    isFound = true
                    
                }
            }
        }
        .addOnFailureListener { exception ->
            Log.w(TAG, "Error getting documents.", exception)
        }
    return isFound
}
I want to return from the method after the loop is completed. how to achieve that?OG
05/17/2020, 7:56 PMcheckOrganization and invoking the callback in the addOnSuccessListener. Another alternative would be changing this interface (if it's internal) and using coroutines so you can return the result asynchronously.OG
05/17/2020, 8:01 PMcheckOrganization a suspend function so you can return the result asynchronously. 
b.) Use traditional callbacks to pass the result at a later time (the end of the for loop in addOnSuccessListener