I have a list of URLs that I need to call and if I got success response for all of them, I can continue.
I can simply do it with RxJava and Retrofit like:
@PUT
fun uploadFile(@Url url: String, @Body file: RequestBody): Single<Response<Void>>
Observable.fromIterable(uploadUrls)
.flatMapSingle {
val requestBody = InputStreamRequestBody(contentResolver, uri)
upsellServiceApi.uploadFile(url, requestBody)
}
.toList()
.subscribeOn(schedulerProvider.io())
.observeOn(schedulerProvider.ui())
.subscribe(
{ responses ->
if (responses.all { it.isSuccessful }) {
// continue
} else {
//error
}
},
{
// error
}
Now I need to do the same thing without retrofit and by only using okhttpclient. How should I do it?