В ViewModel:< /p>
Код: Выделить всё
fun validateList(list: List): Single {
return Observable.fromIterable(list)
.toFlowable(BackpressureStrategy.LATEST)
.map { it.jsonString }
.map { it?.let { VerifiableObject(it) } ?: throw IllegalStateException("Json must not be null") }
.flatMapSingle { validate() }
.toList()
.map {
list.mapIndexed { index, testModel ->
(if (it[index] != null) {
//Updating boolean value here
testModel.isVerified = it[index].toString()
} else throw Exception("ERROR")); testModel
}
}
}
Код: Выделить всё
viewModel. validateList(arrayList)
.doFinally {
showLoading(false)
}
.asyncToUiSingle()
.subscribe({
//Updating UI
adjustCard(it)
}, {
it.printStackTrace()
})
.addTo(disposables)
Код: Выделить всё
data class TestModel(
val title: String,
var isVerified: String? = null,
var reason: String? = null)
Подробнее здесь: https://stackoverflow.com/questions/695 ... -in-rxjava
Мобильная версия