Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CocoaHeads BNE Sept 2014

Ben Stovold
September 02, 2014

CocoaHeads BNE Sept 2014

"Building Realtime Apps", including latest news, Rob Pearson's presentation on ReactiveCocoa, Roger Stephen's presentation on Firebase and Ben Stovold's presentation on putting the two together.

Ben Stovold

September 02, 2014
Tweet

More Decks by Ben Stovold

Other Decks in Technology

Transcript

  1. Universal storyboards, size classes, and Auto Layout combine to enable

    you to design for all devices using a single interface document, and we're bringing this to another area, Launch Images. With iOS 8, you can now provide an Interface Builder document and, at runtime, have the OS generate all of the necessary Launch Images for you. [ Applause ] So now you no longer need to provide the individual assets and you can use the same great design tools for your interfaces and your launch presentations.
  2. Transit Dashboard Pipeline Inputs: * List of Everyday Trips (Favourites)

    * GPS Location * Time Outputs: * Next Transit Trip
  3. RACSignal Example [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; }];
  4. KVO

  5. Key Value Observing // Bind Transit Trips to Table View

    [RACObserve(self.viewModel, everydayTransitTrips) subscribeNext:^(id x) { @strongify(self); [self.tableView reloadData]; }];
  6. rac_signalForSelector [[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]; } }];
  7. Reactive Timer 1 [[[[[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]];
  8. Reactive Timer 2 RACSignal *nextTransitTripIntervalSignal = [RACSignal interval:1 onScheduler:[RACScheduler scheduler]];

    RACSignal *currentUserLocationRefreshDelay = [[RACSignal empty] delay:60]; RACSignal *currentUserLocationRefreshSignal = [[[self.locationService.locationSignal take:1] concat:currentUserLocationRefreshDelay] repeat];
  9. Protips • Start by reading IntroToRx.com • Start small and

    iterate. • Logging w/ Something like Cocoalumberjack • Asks questions by opening issues at http://github.com/ ReactiveCocoa/
  10. References • 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
  11. • backend service for realtime storage and sync • Device-device

    sync e.g. chat, notifications, location • www.firebase.com
  12. Crap's gonna hit the fan Jones, and this place ain't

    prepared for shit! This firebase can’t be defended