Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RxSwift - mapping contentOffset of UITableView

I'm trying to apply some logic to a component when a UITableView is scrolled, but I can't map the contentOffset property to return the y's value.

I'm testing like this but nothing happens:

table.rx.contentOffset.map {debugPrint($0)}

How can I do that?

like image 863
juniorgarcia Avatar asked Jan 03 '23 22:01

juniorgarcia


1 Answers

Map on its own will do nothing. You need to subscribe to the stream:

table.rx.contentOffset.subscribe {
  print("offset now \($0.element)")
}.disposed(by: disposeBag)
like image 61
Rich Tolley Avatar answered Jan 05 '23 16:01

Rich Tolley