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

RxSwiftを用いたアプリ開発の実践

gomi_ningen
November 27, 2015

 RxSwiftを用いたアプリ開発の実践

2015/11/27 - オープンソースライブラリ研究会 - iOS Android Rails編@ビズリーチ
https://connpass.com/event/22476/

gomi_ningen

November 27, 2015
Tweet

More Decks by gomi_ningen

Other Decks in Research

Transcript

  1. ࣗݾ঺հ •  ౦ژͷ๭ࣾͰಇࣾ͘ச̎೥ੜ •  ࢓ࣄɿόονɾ΢Σϒαʔόʔ(Java)ɾiOSΞϓϦ(Swift)  •  ޷͖ͳݴޠ͸Java8 / Scala

    / C# •  ݱ࣌఺Ͱ·ͩiOS։ൃܦݧ̐ϲ݄ఔ౓ͷॳ৺ऀ •  ͱ͋ΔܦҢͰRxSwiftΛ༻͍ͨΞϓϦΛ࡞ͬͯϦϦʔε͠·ͨ͠ •  RxSwift ͷϓϩμΫτͰͷ࣮ફར༻ʹ͍ͭͯ͝঺հ͠·͢ @gomi_ningen
  2. )551ΫϥΠΞϯτͷ࣮૷ •  NSURLSession ͷ RxCocoa֦ுϝιουrx_responseΛ༻͍Δ •  Observable<(NSData!, NSHTTPURLResponse)> Λฦͯ͘͠ΕΔ • 

    ͜ΕΛੜͰ࢖͏ͷͰ͸ͳ͘ɺΫΤϦ΍ϔομΛ෇Ճͨ͠ΓɺλΠϜΞ ΢τ࣌ؒΛઃఆͰ͖ΔΑ͏ʹ͢ΔɺHTTPΫϥΠΞϯτͷػೳ୯Ґͱ͠ ࣮ͯ૷Λߦ͍·ͨ͠ GitHubͰެ։͍ͯ͠·͢ɿhttps://github.com/53ningen/RxHttp
  3. 3Y$PDPBΛ༻͍ͨ6*Πϕϯτॲཧ RxCocoaΛimportͯ͠UIίϯϙʔωϯτͷ֦ுϝιουΛར༻͢Δ •  UIKitͷओཁͳίϯϙʔωϯτʹ͸ObservableΛฦͯ͘͠ΕΔ֦ுϝ ιου͕ఆٛ͞Ε͍ͯΔ •  σϦήʔτͰΠϕϯτॲཧΛ͠ͳ͍ܗͷ࣮૷͕Ͱ͖Δ •  ֦ுϝιου͔ΒಘΒΕΔObservableʹରͯ͠΋ map΍

    filter ͳͲ ͷίϯϏωʔλΛ༻͍Δ͜ͱ͕Ͱ͖Δ •  UIίϯϙʔωϯτʹରͯ͠ͲΜͳ֦ுϝιου͕ఆٛ͞Ε͍ͯΔ͔ʹ ͍ͭͯ͸ҎԼΛࢀর͢Δͱྑ͍ͱࢥ͍·͢ https://github.com/ReactiveX/RxSwift/blob/master/Documentation/API.md
  4. ࣮ߦεϨουͷ੾Γସ͑ ࢖͏εέδϡʔϥʔʹΑ࣮ͬͯߦઓུ͕มΘΔ 2015-11-08 07:40:48.946 xctest[10944:2734414] background 2015-11-08 07:40:48.946 xctest[10944:2734359] main

    2015-11-08 07:40:48.947 xctest[10944:2734423] background 2015-11-08 07:40:48.947 xctest[10944:2734414] background όοΫάϥ΢ϯυͰฒྻʹ࣮ߦ͞Ε͍ͯΔ
  5. ࣮ߦεϨουͷ੾Γସ͑ ࢖͏εέδϡʔϥʔʹΑ࣮ͬͯߦઓུ͕มΘΔ 2015-11-08 07:42:37.552 xctest[11125:2735824] main 2015-11-08 07:42:37.552 xctest[11125:2735881] background

    2015-11-08 07:42:37.552 xctest[11125:2735881] background 2015-11-08 07:42:37.552 xctest[11125:2735881] background όοΫάϥ΢ϯυͰ௚ྻʹ࣮ߦ͞Ε͍ͯΔ
  6. 3YΛར༻͢Δ͜ͱʹΑΔมԽ •  ίʔϧόοΫΛ΄ͱΜͲ࢖ΘͣΠϕϯτॲཧͰ͖Δ •  શମతʹΠϯσϯτͷઙ͍ίʔυʹͳΔ •  ίϯτϩʔϥʔʹΠϕϯτॲཧΛू໿Ͱ͖ΔΑ͏ʹͳΔ •  ఻೻ͤ͞ΔσʔλͷมܗɾϑΟϧλʔͳͲ͕खܰʹߦ͑Δ • 

    map ΍ filterͳͲ൚༻తͳؔ਺Λར༻Ͱ͖Δ •  ίʔϧόοΫॲཧͷܕ߹ΘͤΛߟ͑Δඞཁ͕ͳ͘ͳΔ •  એݴతʹΠϕϯτॲཧΛѻ͑ΔΑ͏ʹͳΔ •  ࣦഊͷ఻೻Λྫ֎Ͱ͸ͳ͍ػߏͰ࣮ݱͰ͖Δ •  ྫ֎Λ༻͍ͳ͍ΤϥʔॲཧΛՄೳʹ͢Δ