While exploring RxSwift
I found just textField.rx_text.asObservable()
property, that fires event every keyboard button is hit.
But how do we handle "search" or "done" button press events? I'd like to fire search only after these actions, not "search as you type".
You can subscribe to UIControlEvents like this:
textField.rx_controlEvents(.EditingDidEndOnExit).subscribeNext {
print("return pressed")
}
In RxSwift 4 and 5:
textField.rx.controlEvent([.editingDidEndOnExit]).subscribe { _ in
print("editingDidEndOnExit")
}.disposed(by: disposeBag)
In Rxswift 3.0
textField.rx.controlEvent([.editingDidEndOnExit])
.subscribe(onNext:{text in
print(text)
}).addDisposableTo(disposeBag)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With