I'll be honest - I did have real problems getting back to grips with ReactiveCocoa 3.0 since their API overhaul (despite being reasonably familiar with v2 - I even gave a talk on it). I'm getting there now (tacks.cc is written extensively with ReactiveCocoa 3.0 RC), and I'll try to update this post with tidbits from what I've learned because, to-date - even though the RAC codebase is well documented, function to function - there's not enough examples out there for how you actually use this stuff as a whole. Most of the example code that exists is still in Objective-C and generally relates to previous versions of RAC. There are some great blog posts (linked at the bottom), which really helped me figure it out.
Creating a signal
We can create a "pipe" which returns a Tuple pair: the Signal itself, and an 'observer' which we can use to manually send events, - events which pop out of the created signal. They go together.
let (self.locationSignal, self.locationObserver) = Signal<CLLocation, NoError>.pipe()
Signal of empty Events:
If you want a Signal that sends empty Next events, create your signal like so:
Signal<Void, NoError>, and just send it Voids:
You don't always need a real Error type
Signals rarely fail, so it's usually easier just to model them using NoError.
let locationSignal: Signal<CLLocation, NoError>
next: to start a new signal after completion - this is gone
In RAC 2, we could use
next: to start a new signal once another completes. We don't this anymore - instead we concatenate signals, for example:
localFetchProducer |> concat(networkFetchProducer)
Create a SignalProducer from a value
let individualComicProducer =