I have a problem which I was unable to solve so far I'm new to RxKotlin so it might be easy. Please have a look at the code:
override fun infos(): Stream<Info> =
client.infoAboutItem(identifier)
.map {
val itemId = it.itemId ?: ""
val item = client.itemForId(itemId)
ClientInfo(client, it, source, item) as Info
}
.let { AccessStream(it) }
Where stream is our self-made collection. Map is a method that allows you to iterate over every item inside that collection.
The problem here is that
client.itemForId(itemId)
is an http call that returns a Single which is not ideal.
I would want to create an asynchronous call inside map that would return Item instead of Single and then pass it to ClientInfo. The things that I've tried so far was was using subscribing inside the map and using blockingGet() method but this blocks the main thread even if I observe and subscribe on a different thread
So it involves making an asynchronous call for every thing in the collection.
Thanks for help
You can try to return
Observable<Stream<Info>>
and then it would look like: