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

ReactiveCocoa Pitfalls at freee

ReactiveCocoa Pitfalls at freee

10/18にfreeeで開催されたReactiveCocoa TokyoのLT資料です
http://connpass.com/event/8680/

http://www.freee.co.jp/

3fe447a7f9238108e6c50e97ac12717a?s=128

Kenichi Yonekawa

October 18, 2014
Tweet

Transcript

  1. ReactiveCocoa Pitfalls at freee @yonekawa

  2. freeeͷiOSΞϓϦ͕ ReactiveCocoaΛಋೖ͔ͯ͠ Β̕ϲ݄͕ܦͪ·ͨ͠

  3. • 2014/12/20 iOSΞϓϦ։ൃணख • 2014/01/10 ReactiveCocoaಋೖ • 2014/02/14 1.0.0ϦϦʔε

  4. ೥຤ʹҰମԿ͕ɾɾɾ

  5. ReactiveCocoaΛ࢖͍ͬͯͯ freeeͰى͖ͨ໰୊΍ ϋϚΓͲ͜ΖΛ঺հ͠·͢ ஫: ReactiveCocoaͷAPI͕ͪΐ͍ͪΐ͍ग़͖ͯ·͢

  6. combineLatestWith

  7. combineLatestWithͱSignalͷ࣮ߦॱ • combineLatestWith͸ฒྻʹSignalΛ࣮ߦ͢Δ ͷͰൃՐ͞ΕΔॱং͸ෆఆɻϩάΠϯ͔ͯ͠Βσʔ λΛऔಘɺΈ͍ͨͳॲཧʹ࢖͏ͱϋϚΔ • ௚ྻʹ͍ͨ࣌͠ʹ͸flattenMapΛ࢖͏

  8. rac_textSignal

  9. rac_textSignal vs RACObserve • textϓϩύςΟʹ௚઀୅ೖ͢ΔΑ͏ͳέʔεͰγ άφϧ͕ൃՐ͠ͳ͍ɻRACObserveͰtextϓϩύ ςΟΛsubscribe͢ΔͱൃՐ͢Δ • ٯʹΩʔϘʔυ͔Βͷೖྗ͸RACObserveͩͱൃՐ ͠ͳ͍ɻrac_textSignalͰऔΒͳ͍ͱ͍͚ͳ͍

    • combineLatestͯ྆͠ํൃՐ͢ΔsignalΛ࡞ͬ ͨΓͨ͠
  10. sendCompleted

  11. None
  12. sendErrorͷޙͷsendCompleted • sendErrorͷޙʹsendCompletedΛݺΜͰ΋ݺ ͹Εͳ͍ɻ • subscribe͢ΔଆͰnextͱerrorͰڞ௨Ͱ΍Γͨ ͍ॲཧʢΠϯδέʔλΛࢭΊΔͱ͔ʣΛॻ͖͍ͨ࣌ ʹ͸ݸผʹॻ͔ͳ͍ͱ͍͚ͳ͍

  13. [RACSignal empty]

  14. None
  15. [RACSignal empty] • RACSignalϕʔεͰ΍ΓऔΓ͍ͯ͠Δ࣌ɺ [RACSignal empty]Λฦ͢ͱ౰વnext΋error΋ൃ Ր͞Εͳ͍ • subscribeલʹΠϯδέʔλΛճͯ͠nextͱerrorͰ ࢭΊ͍ͯΔ৔߹ɺΠϯδέʔλ͕ճΓͬͺͳ͠ʹͳΔ

    • empty͡Όͳۭͯ͘ͷ݁ՌΛฦ͢SignalΛฦ͢ͷ͕Α ͦ͞͏
  16. UITableView

  17. Cellͷதʹsubscribe͍ͨ͠View͕͋Δ࣌ • ηϧ͕࠶ར༻͞ΕΔͱೋॏʹϑΥʔ ϜͷΠϕϯτΛsubscribeͯ͠ ͠·͏ • reloadͳͲߟ͑Δͱ subscriberΛഁغ͢ΔλΠϛϯ ά͕೉͍͠ •

    ݱঢ়͸ۤ೑ͷࡦͰ࠶ར༻΍ΊͨΓ ͯ͠Δ
  18. ReactiveCocoa3.0

  19. ReactiveCocoa3.0 • LTͷͨΊʹແ஡ͯ͠ಋೖ͠Α͏ͱௐ΂ͨ • طଘͷRACSignalϕʔεͷΠϯλϑΣʔεΛ asColdSignalͱ͔Ͱ͖Δͷ͸ָͦ͏ͩͬͨ • υΩϡϝϯτແ͠Ͱ࢖͍ํΛ୳Δͷ௒೉͍͠