Upvote:31

Aprove answer
searchBar
    .rx.text // Observable property thanks to RxCocoa
    .orEmpty // Make it non-optional
    .debounce(.milliseconds(500), scheduler: MainScheduler.instance) // Wait 0.5 for changes.
    .distinctUntilChanged() // If they didn't occur, check if the new value is the same as old.
    .filter { !$0.isEmpty }

Upvote:8

.debounce(RxTimeInterval.milliseconds(500), scheduler: MainScheduler.instance)

Credit Goes to: stackoverflow.com

Related question with same questions but different answers