

^ Unreleased App. Code Examples. Please be kind ...
- Functional Programming Briefly
- Signals and Pipelines
- RAC Lessons Learned
Functional Programming Briefly
^ Purity: f(x) = x + 1 ^ Output is calculated soley on its inputs ^ Repeatable ^ No Side Effects ^ Immutable Data
^ Higher Order Functions: Input or Output is a Function ^ map, reduce, filter, concat, take ...
Signals and Pipelines
Inputs:
- List of Everyday Trips (Favourites)
- GPS Location
- Time
Outputs:
- Next Transit Trip
^ It's all about Inputs and Outputs
[RACSignal createSignal:^(id<RACSubscriber subscriber) {
// Do Something
u_int32_t r = arc4random();
// Start (and in this case complete) the signal.
[subscriber sendNext:@(r)];
[subscriber sendCompleted];
return (RACDisposable *)nil;
}];
^ This is worth the dependency
^ This is worth the dependency
// Bind Transit Trips to Table View
[RACObserve(self.viewModel, everydayTransitTrips) subscribeNext:^(id x) {
@strongify(self);
[self.tableView reloadData];
}];
[[self rac_signalForSelector:@selector(searchBar:textDidChange:) fromProtocol:@protocol(UISearchBarDelegate)] subscribeNext:^(RACTuple *value) {
@strongify(self);
UISearchBar *searchBar = value.first;
if (searchBar == self.departingLocationsSearchBar) {
[self.viewModel filterDepartingLocationsByName:self.departingLocationsSearchBar.text];
}
else {
[self.viewModel filterArrivingLocationsByName:self.arrivingLocationsSearchBar.text];
}
}];
^ Touch Events, Notifications, Reachability etc.
RACSignal *appActiveSignal = [[[[NSNotificationCenter.defaultCenter
rac_addObserverForName:UIApplicationDidBecomeActiveNotification object:nil] mapReplace:@YES]
startWith:@YES]
setNameWithFormat:@"%@ appActive", self];
[[[[[RACSignal interval:60 onScheduler:[RACScheduler scheduler]]
map:^id(NSDate *timestamp) {
@strongify(self);
if (self.hasEverydayTrips != nil && [@(YES) isEqualToNumber:self.hasEverydayTrips]) {
return @"SEQ";
}
else {
return @"Everyday Transit";
}
}]
startWith:@"Everyday Transit"]
distinctUntilChanged]
deliverOn:[RACScheduler mainThreadScheduler]];
RACSignal *nextTransitTripIntervalSignal = [RACSignal interval:1 onScheduler:[RACScheduler scheduler]];
RACSignal *currentUserLocationRefreshDelay = [[RACSignal empty] delay:60];
RACSignal *currentUserLocationRefreshSignal = [[[self.locationService.locationSignal
take:1]
concat:currentUserLocationRefreshDelay]
repeat];
- Start by reading IntroToRx.com
- Start small and iterate.
- Logging w/ Something like Cocoalumberjack
- Asks questions by opening issues at http://github.com/ReactiveCocoa/
- Thinking like a Functional Programmer
- ReactiveCocoa Doco
- Debugging
- Github Repo: http://github.com/ReactiveCocoa/
- Ray Wenderlich Tutorial: https://bit.ly/1rXA31Y
- Big Nerd Ranch Tutorial: https://bit.ly/1mp04mI
- FRP on iOS by Ash Furrow: https://leanpub.com/iosfrp
- Brent Simmons on ReactiveCocoa: https://bit.ly/PcyjCL
Questions?



