trouble implementing an error wrapper in firestore callbacks

Use suspendCoroutine or suspendCancellableCoroutine

suspend fun getAllApplicationActivities(groupsList: List<String>) = suspendCoroutine { cont ->
    Firebase.firestore.collection(ACTIVITIES_COLLECTION)
        .whereIn(GROUP_ID, groupsList)
        .get()
        .addOnSuccessListener { documents ->
            val activitiesList = documents.toObjects(ActivityCollectionModel::class.java)
            cont.resume(activitiesList)
        }
        .addOnFailureListener { exception ->
            cont.resumeWithException(exception)
        }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top