I have a function that loop the request using Retrofit and RXJava as below
for (i in month..12) {
if (Conn.connection(applicationContext)) {
Api.create().getDateInMonth("2019-$i-01")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<DateDataResponse> {
override fun onSubscribe(d: Disposable) {}
@SuppressLint("NewApi")
override fun onNext(dateDataResponse: DateDataResponse) {
Log.d("OnSuccess", "success")
}
@SuppressLint("NewApi")
override fun onError(e: Throwable) {
Log.d("onError", "error" + e.message)
}
override fun onComplete() {
Log.d("onComplete", "onComplete")
}
})
} else
Log.d("onError", "No Internet Connection")
}
}
so if some request error or success it will go on until the 12 request is finish. I want to detect if I already got all response from my request