Last active
April 11, 2018 06:40
-
-
Save rajajawahar/e461f812eb19c36d5f32f7ade7e966d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
import RxCocoa | |
import Alamofire | |
import RxSwiftExt | |
class ViewController: UIViewController { | |
let disposeBag = DisposeBag() | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
textFieldSample() | |
} | |
private func textFieldSample() { | |
textField.rx.text | |
.debounce(0.4, scheduler: MainScheduler.instance) //Here we wait 0.3 seconds to be sure that user doesn't want to tap multiple times | |
.subscribe(onNext: { [weak self] text in | |
self?.search(withQuery: text); | |
}).addDisposableTo(disposeBag) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment