Reputation: 361
I need to handle UITextField statuses.
So I bind my emailTextField with this way
Observable.combineLatest(
emailTxf.rx.controlEvent(.editingDidBegin),
emailTxf.rx.controlEvent(.editingChanged),
emailTxf.rx.controlEvent(.editingDidEnd))
.asObservable()
.subscribe(onNext: { [weak self] _ in
// DoSomething()
}).disposed(by: disposeBag)
This code can't cover the clear button on UITextField.
So If I press the clear button after writing something on UITextField, It doesn't detect the textField status.
I know there is allEditingEvents control event.
But not sure it's okay to use allEditingEvents for detecting clear button
Is this okay to use allEditingEvents? or is there better way to handle it?
Upvotes: 1
Views: 988
Reputation: 76
You can observe emailTxf.rx.text
directly and check if the text is empty. This should cover the case for clear button
Upvotes: 2