I need to indicate some state with delay, while user is typing. I'm trying to use RxSwift:
_textField.rx.text.orEmpty.debounce(3, scheduler: MainScheduler.instance).distinctUntilChanged().subscribe({[weak self] _ in
self?.typeViewShould(hide: true)
}).addDisposableTo(disposeBag)
The problem is after 3 seconds, I want to wait, block executes as many times as characters I entered, and not only once with latest value. I tried to rewrite code from GitHub example search, but it doesn't work:
_ = _textField.rx.text.orEmpty.debounce(3, scheduler: MainScheduler.instance).distinctUntilChanged().flatMapLatest {[weak self] query -> Observable<[String]> in
self?._textField.text = nil
self?.typeViewShould(hide: true)
return .just([])
}.observeOn(MainScheduler.instance)
What am I doing wrong?