Use of unresolved operator '<~'

1.8k Views Asked by At

I am using ReactiveCocoa 5.0 alpha 3, ReactiveSwift and Swift 3

I am having issues with binding my UITextField to a MutableProperty.

In ReactiveCocoa 4, I used this:-

extension UITextField {
    func signalProducer() -> SignalProducer<String, NoError> {
        return self.rac_textSignal().toSignalProducer()
            .map { $0 as! String }
            .flatMapError { _ in return SignalProducer<String, NoError>.empty }
    }
}

viewModel.email <~ emailTextField.signalProducer()

But now in ReactiveCocoa 5, I am not able to do that. From what I understand, I am supposed to do something like this I guess:-

viewModel.email <~ emailTextField.reactive.textValues

But either it says '<~' is unresolved or textValues is not a property.

Please help me bind this.

1

There are 1 best solutions below

0
Shaw On

The <~ in Rac5 is a function for binding a BindingTarget with a signal, u can use it like this:

placeHolderLabel.reactive.isHidden <~
        self.reactive
        .values(forKeyPath: #keyPath(passwordTF.text))
        .map({ (value) -> Bool in
            let value = value as! String
            return !value.isEmpty
        })

or this:

let buttonEnabled = MutableProperty<Bool>(false)

button.reactive.isEnabled <~ buttonEnabled

And make sure you have imported the module ReactiveSwift in the files which you use <~ .