Reputation: 10254
In my expression, even takeUntil
is true/false, subscribe method is emitting all the list items, which should stop once takeUntil
is true right?
Observable.fromIterable(countryResponseList.withIndex())
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.takeUntil((index,item) -> item.getId() == currentCountryCodeId)
.subscribe((index,item) -> run{
Log.d("items and index", " ${item} and ${index}")
})
What i need is to get the current index, when the expressions match( item.getId() == currentCountryCodeId) each other and the RxJava expression should stop continuing. I don't know how to do that, any help appreciated. I also found forEachWhile
, will that suit this situation?
Upvotes: 1
Views: 300
Reputation: 342
I'm not sure you want to stop iterating countryResponseList.withIndex()
. If so, the upstream should be run on the same thread with takeUntil
.
Hope underlying is what you want. If not, how about describe more in detail?
Observable.fromIterable(countryResponseList.withIndex())
.takeUntil((index,item) -> item.getId() == currentCountryCodeId)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe((index,item) -> run{
Log.d("items and index", " ${item} and ${index}")
})
Upvotes: 1