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

ゆるやかなReactiveCocoaの導入

ninjinkun
August 03, 2014

 ゆるやかなReactiveCocoaの導入

Fablic社でのReactiveCocoaの(ゆるい)導入事例

ninjinkun

August 03, 2014
Tweet

More Decks by ninjinkun

Other Decks in Programming

Transcript

  1. EFMFHBUFϥούʔ w EFMFHBUFϝιουΛ࢖Θͣʹͦͷ৔ͰCMPDLΛ౉ͤ Δ w #MPDLT,JUͱಉ͡༻్ UIAlertView *alertView = [[UIAlertView

    alloc] initWith…]; [[alertView rac_buttonClickedSignal] subscribeNext:^(NSNumber *buttonIndex) { switch ([buttonIndex integerValue]) { case 1: do some thing… break; case 2: do something … break; default: break; } }]; [alertView show];
  2. 3"$Ͱ.77. w 7JFX7JFX.PEFMؒΛCJOEJOH w 7JFX.PEFMͷߋ৽͸ࣗಈతʹ7JFXʹ൓ө 7JFX 7JFX.PEFM .PEFM 6*7JFX 6*7JFX$POUSPMMFS

    3"$ͰCJOEJOH RAC(self.detailMessageLabel, text) = [RACObserve(self, detailMessage) filter:^BOOL(NSString *message) { return message.length; }];
  3. ๻ͷߟ͑ΔΏΔ͍.77. w ͱʹ͔͘.VUBCMFͳ΋ͷ͸7.ʹूΊΔ w +40/͔Βੜ੒͞Εͨ/40CKFDU͸*NNVUBCMFʹ w 7.ʹର͢ΔϢχοτςετΛॻ͘ w 3"$͸CJOEͷΈʹ࢖͏ FLItem

    *item = self.items[indexPath.item]; ! __weak typeof(self) weakSelf = self; // ৄࡉͰLikeΛ֎ͨ͠ΒҰཡͰ΋Like͕֎ΕΔΑ͏ʹ͢Δ [RACObserve(item, liked) subscribeNext:^(id x) { [weakSelf.collectionView reloadItemsAtIndexPaths:@[indexPath]]; }];
  4. 'SJMͷ঎඼7. λΠϜϥΠϯ"1* ঎඼ ঎඼ৄࡉ"1* αΠζ ഑ૹྉ ഑ૹํ๏ ίϝϯτ ঎඼໊ ϒϥϯυ

    Ձ֨ ঎඼ ঎඼ αΠζ ഑ૹྉ ഑ૹํ๏ ίϝϯτ ঎඼໊ ϒϥϯυ Ձ֨ ঎඼7JFX.PEFM