I am fairly new to IOS development and working on a small project, I am trying to subscribe to UITextView using Rxswift. However, I can't seem to find any way to do so online or by following what I did to UITextField.
this is what I Done and its working for TextField:
TextField.rx.controlEvent(.editingChanged).withLatestFrom(textField.rx.text.orEmpty)subscribe(onNext : { text in
self.viewModel.address.accept(text)
Some code goes here
Now doing the same thing for a textView
TextView.rx.controlEvent(.editingChanged).withLatestFrom(TextView.rx.text.orEmpty)subscribe(onNext : { text in
self.viewModel.address.accept(text)
I get the following error: Referencing instance method 'controlEvent' on 'Reactive' requires that 'UITextView' inherit from 'UIControl'
I am really confused on how to make controlEvent work with UITextField. it doesn't show in the suggested code when I use rx.
It's much easier than what you have in your question...
And the subscribe you have can be much simpler as well:
However, keep in mind:
Break yourself of the habit of binding everything to a Relay or Subject now and you will find your future in Rx much easier.