I am using RxJava3 in my project and I can't write a request, I've been wrestling my head for several hours.
I have List<Stream> and have a function that returns a Single<List<Topic>> by Stream, i want to get a Single<Map<Stream, List<Topic>>>,
fun getMockTopics(streamId: Long): Single<List<Topic>> {
return Single.just(listOf(Topic(1, "")))
}
typealias SteamTopics = Map<Stream, List<Topic>>
override fun getTopics(streams: List<Stream?>): Single<SteamTopics> {
return Observable.fromCallable { streams.filterNotNull() }.flatMapIterable { it }
.map { stream ->
Pair(stream, getMockTopics(streamId = stream.streamId))
}.flatMap {
TODO("???")
}
.toMap({ it.first }, { it.second })
}