Suppose I have getPeople(): List<Person>
and getStudent(ssn: String): Student
data class Person(val name: String, val ssn: String)
data class Student(val ssn: String, val grade: Char)
data class ReportCard(val name: String, val grade: Char)
I want a List<ReportCard>
but I don’t want to wait for getStudent to form a report card. For example, if getPeople() returns [(“Joy”, “111”), (“Tom”, “123”), (“Jerry”, “567”)] and Joy got a C, Tom got an A, and Jerry got an F, I want it to emit like
(“Joy”, ”)
(“Tom”, ”)
(“Joy”, ‘C’)
(“Jerry”, ”)
(“Tom”, ‘A’)
(“Jerry”, ‘F’)
The idea is that for each Person I use the ssn to make a network call to get a Student, but I don’t wait for Student to form a ReportCard, I can just return blank. When the network call for Student is done I will emit again with the complete Report Card.I thought I could do something like
getPeopleFlow().map { person -> getStudent(person.ssn) }.flatMapMerge
but flatMapMerge is not available. Another note is that if I encounter any errors it should fail silently, and default to an empty string.