I have a method that returns an Observable like this:
open fun get(): Observable<Response> {
return if (condition)
getDataFromApi()
else
getDataFromDb()
}
and is subscribed as followed:
get()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(/*a object of class extending DefaultObserver*/)
I am facing this issue when getDataFromDb() is called and after a while getDataFromApi() is called as per condition. For first call it works fine but on second call onNext is called more then one time with the old data response from getDataFromDb(). Please let me know what I am doing wrong. I am a bit new to RxJava.