원문 링크:

https://pilgwon.github.io/blog/2017/09/26/RxSwift-By-Examples-1-The-Basics.html

 

예제로 시작하는 RxSwift #1 - 기초

RXSWIFT BY EXAMPLES #1 – THE BASICS.

pilgwon.github.io

버전이 달라서 그런지 속성이 약간 다릅니다.

기존 코드는 swift 3 이어서 빌드가 안됩니다.

searchBar
  .rx.text // RxCocoa의 Observable 속성
  .orEmpty // 옵셔널이 아니도록 만듭니다.
  .debounce(RxTimeInterval.milliseconds(500), scheduler: MainScheduler.instance)
  .distinctUntilChanged()
  .subscribe(onNext: { [unowned self] query in
  self.shownCities = self.allCities.filter { $0.hasPrefix(query) }
  self.tableView.reloadData()
  })
  .disposed(by: disposeBag)

.debounce .disposed 부분이 차이가 있습니다.

자세한 내용은 원문을 참고해주세요.

제가 만들어본 소스 git 링크: https://github.com/SungKihun/CitySearcher.git

+ Recent posts