Answer the question
In order to leave comments, you need to log in
How to filter Single?
There is a method that returns Single>:
@GET("task-m-001/list.php")
fun getItems(): Single<List<String>>
fun getItems(){
_networkState.postValue(NetworkState.LOADING)
try {
compositeDisposable.add(
apiService.getItems()
.observeOn(Schedulers.io())
.subscribeOn(Schedulers.io())
.subscribe({
val itemsResponse = itemsResponseConverter.getItemResponse(it)
_downloadedItemsResponse.postValue(itemsResponse)
_networkState.postValue(NetworkState.LOADED)
},
{
_networkState.postValue(NetworkState.ERROR)
})
)
}catch (e: Exception) {
Log.e(TAG, e.message.toString())
}
}
Answer the question
In order to leave comments, you need to log in
Didn't see flatMap in your code.
But in general it will be like this
getItems()
.flatMapObservable { items ->
Observable.fromIterable(items).switchMap { "прозвонить ссылку, что бы это не значило" }
}.toList()
Single<List<String>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question