Kulwinder Singh
11/08/2019, 8:12 AMLiveData<List<User>>
loaded from firestore now i want to load `Appointment`s for each user from firestore, in end i want to create something like this Map<User,Appointment>
.
which flow
operator can helps me in this situation, or flow is not best suited for this?Zach Klippenstein (he/him) [MOD]
11/08/2019, 6:00 PMList<User>
you can just do something like:
users
.map { user ->
user to async { loadAppointments(user) }
} // List<Pair<User, Deferred<Appointment>>>
.toMap() // Map<User, Deferred<Appointment>>
// This is an inline operator so it's allowed to make suspending calls if you're already in a suspend function.
.mapValues { it.value.await() } // Map<User, Appointment>