Fredrik Larsen
04/05/2019, 7:30 AMgildor
04/05/2019, 7:41 AMtseisel
04/05/2019, 7:43 AMSingle
by suspend functions that return a non-null object,
- Maybe
by suspend functions that return a nullable object,
- Completable
by suspend functions that return Unit
.
Since yesterday, you can play with the preview of the new Flow
API, that is intended to replace usages of Observable
and Flowable
in the long run.mySingle.map { element ->
runBlocking {
suspendingTransform(element)
}
}
Fredrik Larsen
04/05/2019, 8:19 AMgildor
04/05/2019, 8:20 AMAs far as I can see you’re losing the error handling if you do thatNo you do not loose actually, in this case if
suspendingTransform
will throw exception, map will catch it and propagate downstream, very similar to what you have with flatMap
streetsofboston
04/05/2019, 11:15 AMFredrik Larsen
04/05/2019, 11:23 AMstreetsofboston
04/05/2019, 11:24 AMFredrik Larsen
04/05/2019, 11:25 AMstreetsofboston
04/05/2019, 11:26 AM