detect when reached tableview bottom
if not bottom return Observable.empty()
if tableview is bottom return Observable.just(())
as i Know is Observable.empty()
is not calling onNext
but empty()
or just()
calling onNext
tableView.rx.contentOffset
.map {
self.isNearTheBottomEdge(contentOffset: $0, self.tableView) && self.postModel.isLoadingComplete.value
? Observable.just(())
: Observable.empty()
}
.throttle(3, scheduler: MainScheduler.instance)
.subscribe(onNext: {
print("reached bottom")
self.postModel.nextPage.onNext(())
},onCompleted: {
print("complete")
}
)
.disposed(by: disposeBag)
return Observable.empty()
in debug but always print("reached bottom")
If you want to have subscribe(onNext)
to be not called on Observable.empty(), just change .map{}
to .flatMap{}
tableView.rx.contentOffset
.flatMap {
self.isNearTheBottomEdge(contentOffset: $0, self.tableView) && self.postModel.isLoadingComplete.value
? Observable.just(())
: Observable.empty()
}
Here you can read about difference between map
vs flatMap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With