How to handle pressing the Finish key in rxSwift?

When researching RxSwift

I found only the textField.rx_text.asObservable() property, which raises the event that each key is pressed on.

But how do we handle click or search button events? I would like to start the search only after these actions, and not "search by type".

+7
reactive-programming swift2 rx-swift
source share
3 answers

You can subscribe to UIControlEvents as follows:

textField.rx_controlEvents(.EditingDidEndOnExit).subscribeNext { print("return pressed") }

+20
source share

In Rxswift 3.0

 textField.rx.controlEvent([.editingDidEndOnExit]) .subscribe(onNext:{text in print(text) }).addDisposableTo(disposeBag) 
+2
source share

In RxSwift 4:

 textField.rx.controlEvent([.editingDidEndOnExit]).subscribe { text in print(text) }.disposed(by: disposeBag) 
+2
source share

All Articles