Skip to content

Instantly share code, notes, and snippets.

@Arrlindii
Created August 13, 2018 22:12
Show Gist options
  • Select an option

  • Save Arrlindii/404f535ed730ef5eaf9931ef79e9a301 to your computer and use it in GitHub Desktop.

Select an option

Save Arrlindii/404f535ed730ef5eaf9931ef79e9a301 to your computer and use it in GitHub Desktop.
extension UIScrollView {
func loadNextPageObservable() -> Observable<Void> {
return rx.contentOffset
.skipWhile {
$0.y < self.frame.size.height
}.map { contentOffset -> Bool in
let padding = CGFloat(20.0)
return contentOffset.y + self.frame.size.height + padding > self.contentSize.height
}.distinctUntilChanged().map { shouldLoad in
if shouldLoad {
Void()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment