An example

Let's suppose that we have an outlet and we want to observe its changes:

@IBOutlet weak var textFieldUserName: UITextField! 

We can create a SignalProducer as follows:

let userNameSignalProducer = textFieldUserName.rac_textSignal().toSignalProducer.map { 
text in
text as! String
}

The rac_textSignal method is a ReactiveCocoa extension for UITextField that can be used to create the signal producer.

Then, we can start our SignalProducer as follows:

userNameSignalProducer.startWithNext {  
results in
print("User name:(results)")
}

This will print any changes in our textField to the console.

Also, we can execute operations such as map, flatMap, filter, and reduce on this signal producer, which we covered in Chapter 6, Map, Filter, and Reduce.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset