could someone help, please?
I have these functions
fun getBooks(): Single<List<Book>> {
return getCollections()
.map {
it.map(::collectonToBook)
}
}
fun getCollections(): Single<List<Collection>> {
return db.fetchCollections()
.filter(::isBook)
}
fun collectonToBook(collection: Collection): Maybe<Book> {
return collection.toBook()
}
The problem is getBooks returns Single<List<Maybe<Book>>>
when I need Single<List<Book>>
. Can I do that inside the stream without calling blockingGet?
Try this:
In words, unwrap the inner
List
into its elements, transform theCollection
into aBook
, concatenate their respectiveMaybe
sources, then finally collect theBook
s into aList
again.