How to handle "Done" return key press event in rxSwift?

alex picture alex · Oct 24, 2015 · Viewed 11.3k times · Source

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".

Answer

louoso picture louoso · Oct 25, 2015

You can subscribe to UIControlEvents like this:

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