いまさら聞けないRxSwift入門

 いまさら聞けないRxSwift入門

モバイルメソッド大阪第一回 RxSwift入門資料です。

0886c70b5ecf3b0b0ee6500c5e47884d?s=128

M.Inomata

May 10, 2018
Tweet

Transcript

  1. ͍·͞Βฉ͚ͳ͍ RxSwiftೖ໳ גࣜձࣾ tech vein ழມ ॆԝ

  2. ࣗݾ঺հ גࣜձࣾ tech vein ୅ද ழມ ॆԝ (͍ͷ·ͨ ΈͭͻΖ) ձࣾHP:

    https://www.tech-vein.com/ private twitter: @ino2222
  3. ެ։தͷAndroid/iOSΞϓϦ ι΢ϧΞϯϦʔγϡ ࣗ෼ͷΦϦΩϟϥΛ࡞ΔεϚϗ31( IUUQTPVOUFDIWFJODPN IUUQTCJUMZ);BV3 $IJJ2 ஍ҬͰॿ͚߹͑Δಗ໊૬ஊΞϓϦ IUUQTBQQMFDP,[IYD ϙέοτΞϒετϥΫτ ҩྍैࣄऀ޲͚ͷ࠷৽δϟʔφϧӾཡΞϓϦ

  4. ࠓ೔͓࿩͢Δ͜ͱ • RxSwiftͱ͸ • RxSwiftͷجຊ • ͜Ε͚֮ͩ͑ͨΒ࢖͑ΔΑ͏ʹͳΔ͔΋ʁ

  5. ࠓ೔͓࿩͠ͳ͍͜ͱ(஌ͬͯΔਓ޲͚) • Cold -> Hot ม׵ • Reactive Streams(backPressure ͳͲ)

  6. RxSwiftͱ͸ • ֤ݴޠͰ࣮૷͞Ε͍ͯΔʮRx(Reactive Extension)ʯ
 ͷSwift޲͚ϥΠϒϥϦ • Reactive Extension … ΋ͱ΋ͱ͸


    C#.NET Ͱ࢖ΘΕͩͨ͠ Rx.NET ͕ΦϦδφϧ • Java(RxJava), JavaScript(RxJS), C++(RxCpp), Ruby(Rx.rb), PHP(RxPHP) ͳͲͳͲଟ਺
  7. ReactiveXͱ͸Կ͔ʁ ReactiveX = Reactive Extension Reactive Programming ʹ൓ԠతϓϩάϥϛϯάΛ͢Δͨ Ίͷ Extension

    = ֦ு ReactiveX͸ - σβΠϯύλʔϯͷ Observable ύλʔϯ - σβΠϯύλʔϯͷ Iterator ύλʔϯ - ؔ਺ܕϓϩάϥϛϯά Λ૊Έ߹Θͤͯ࡞ΒΕͨϥΠϒϥϦͷ͜ͱ
  8. Observerύλʔϯ σʔλΛ؂ࢹ͢Δਓͱ఻͑Δ࢓૊ΈΛ ந৅Խͨ͠σβΠϯύλʔϯ ͕͜͜େࣄʂ

  9. Iterator ύλʔϯ https://ja.wikipedia.org/wiki/Iterator_ύλʔϯ Ұ࿈ͷσʔλΛॱ൪ʹॲཧ͢ΔσβΠϯύλʔϯ ͕͜͜େࣄʂ

  10. ؔ਺ܕϓϩάϥϛϯά ˠ ͦΕͧΕͷؔ਺͸ */065ʹ͔͠ Өڹ͠ͳ͍ ʹ෭࡞༻͕ͳ͍

  11. ͦͯ͠Rx΁…

  12. ͕͜͜خ͍͠RxSwift ࣌ܥྻσʔλΛؚΉɺ͋ΒΏΔσʔλΛετϦʔϜͱͯ͠εϚʔτʹॲཧͰ͖Δɻ ετϦʔϜͱͯ͠ॱ൪ʹॲཧͰ͖Δ͜ͱͰɺ΍΍͍͜͠ඇಉظ੍ޚ͕γϯϓϧʹͳΔɻ →ίʔϧόοΫ஍ࠈ͔Βͷղ์ ந৅ԽʹΑΓૹΓखɾड͚औΓखΛ௚઀஌Βͳ͍··ॲཧ͕ग़དྷΔͷͰૄ݁߹ʹͳΔɻ →վมͷӨڹൣғ͕খ͘͞ͳΔ →෦඼Խɾڞ௨Խ͕ਐΉ ֤छετϦʔϜΛѻ͏ศརͳಓ۩͕ἧ͍ͬͯΔɻ →ετϦʔϜͷੜ੒ɾม׵ɾ߹੒Λߦ͏ΦϖϨʔλ܈ →ετϦʔϜͷεϨου੾Γସ͑ػೳ

  13. RxSwiftͷجຊ

  14. RxSwiftͷجຊ ͜Ε͚ͩ஌ͬͯͨΒ RxŧŔŕŪɹɹ ũƄŝſͬͯݴ͑Δ

  15. RxSwiftͷجຊ ͜Ε͚ͩ஌ͬͯͨΒ RxŧŔŕŪ(ŦƄş)ũƄŝſͬͯݴ͑Δ͔΋ʁ

  16. Observable, Subject, Disposable ΩϞʹͳΔͷ͸ɺ ͜ͷ̏ܥ౷ͷΫϥε(ϓϩτίϧ)ɻ Ϋϥε͸৭ʑ͋Γ·͕͢ɺ ͍͍ͩͨ͜ΕΒͷ஥ؒͰ͢ɻ

  17. + subscribe() Observable + onNext() + onError() + onCompleted() +

    subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋ Observable, Subject, Disposable
  18. Observable<T> ௚༁͢Δͱɺ؂ࢹ͢Δ͜ͱ͕Ͱ͖Δର৅ɻ ೚ҙͷܕ T ʹ͍ͭͯɺ؂ࢹͯ͠σʔλʢΠϕϯτ)Λड͚औ Δࣄ͕Ͱ͖ΔΫϥεɾΠϯελϯεͰ͢ɻ ࣌ܥྻͰσʔλ͕ObservableʹྲྀΕΔ͜ͱ͔Βɺ Observable͸ετϦʔϜ(Stream)ͱ΋ݺͼ·͢ɻ + subscribe()

    Observable + onNext() + onError() + onCompleted() + subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋
  19. “Hello” “Rx” “World” Observable<String> completed ࣌ؒͷྲྀΕ ࣮ߦ݁ՌɿԼͷॱʹग़ྗ͞ΕΔɻ OFYU )FMMP OFYU

    3Y OFYU 8PSME DPNQMFUFE
  20. Subject ؆୯ʹݴ͏ͱɺ೚ҙͷσʔλΛྲྀ͢ػೳ(Observer ͱͯ͠ͷػೳ)Λ࣋ͬͨObservable࣮૷ɻ RxSwift ͷSubject͸ PublishSubject, BehaviorSubject, ReplaySubject ͷ̏छྨɻ +

    subscribe() Observable + onNext() + onError() + onCompleted() + subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋
  21. Subject͸ObserverΛܧঝ͍ͯ͠ΔͷͰ Observableͱͯ͠ѻ͑Δɻ Subject͸onNext(), onComplete(), onError() ͳͲͷσʔλɾΠϕϯτൃ৴ϝιουΛ࣋ͭɻ

  22. ετϦʔϜͷΠϕϯτ • next
 σʔλ͕ਖ਼͘͠ྲྀΕ͖ͯͨͱ͍͏Πϕϯτɻ೚ҙͷܕͷσʔλΛҾ਺ʹ࣋ ͭɻ • error
 ετϦʔϜத͕Τϥʔ(ྫ֎)Ͱҟৗఀࢭͨ࣌͠ʹྲྀΕΔΠϕϯτɻൃੜͨ͠ ΤϥʔΛҾ਺ʹ࣋ͭɻ •

    completed
 ετϦʔϜ͕ਖ਼͘͠׬ྃͨ࣌͠ʹൃੜ͢ΔΠϕϯτɻετϦʔϜͷ࠷ޙʹ Ұ౓͚ͩൃੜ͢Δɻ
 ʢೖྗΛ଴ͪଓ͚͍ͨͱ͖͸completedΛྲྀ͞ͳ͍ʣ
  23. ετϦʔϜͷΠϕϯτ next completed next next next next next completed next

    next ετϦʔϜ͸ next ͰσʔλΛྲྀ͠ɺDPNQMFUFEͰऴྃ͢Δ DPNQMFUFE͕དྷͨΒɺͦͷઌ͸OFYUFSSPS͸ྲྀͤͳ͍ next next next FSSPS ྫ֎ ͕དྷͨΒɺͦͷઌ͸OFYUDPNQMFUFEFSSPS͸ྲྀͤͳ͍ error
  24. RxSwift ͷ Subject࢖͍෼͚ ɾPublishSubject ɹաڈͷσʔλΛอ࣋͠ͳ͍Subjectɻ ɹར༻ྫɿϘλϯͷλοϓΠϕϯτ ɾBehaviorSubject ɹաڈͷσʔλͷ͏ͪ௚ۙͷ̍ͭΛอ͍࣋ͯ͠ΔSubjectɻ ɹར༻ྫɿεΠονON/OFFঢ়ଶɾϢʔβεςʔλεͳͲ ɾReplaySubject.create(bufferSize:

    Int) ɹաڈͷ௚ۙσʔλΛࢦఆόοϑΝʹೖΔ͚ͩอ͍࣋ͯ͠ΔSubjectɻ ɹόοϑΝαΠζ̌ͳΒPublishSubjectͱಉ͡ɻ ɹόοϑΝαΠζ̍ͳΒBehaviorSubjectͱಉ͡ɻ ɹར༻ྫɿࢥ͍͔ͭͳ͍…ཤྺܥͰ࢖͑Δ͔΋ʁ
  25. PublishSubject PublishSubject<T> completed ࣌ؒͷྲྀΕ TVCTDSJCF TVCTDSJCF

  26. BehaviorSubject BehaviorSubject<T> completed ࣌ؒͷྲྀΕ TVCTDSJCF TVCTDSJCF TVCTDSJCF

  27. ReplaySubject ReplaySubject<T>.create(bufferSize: 2) completed ࣌ؒͷྲྀΕ TVCTDSJCF TVCTDSJCF TVCTDSJCF

  28. Disposable ௚༁͢Δͱɺഇغɾॲ෼Ͱ͖Δ΋ͷɻ ObservableΛ subscribe(ߪಡ) ͢Δͱ໭Γ஋ͱͯ͠ Disposable Λ ฦ͠·͢ɻ Disposableʹରͯ͠dispose()ΛݺͿ͜ͱͰɺඇಉظॲཧͷΩϟϯη ϧͳͲɺ؂ࢹ͢Δଆͱͯ͠ॲཧΛࢭΊΔࣄ͕Ͱ͖·͢ɻ

    ྫɿը໘Λดͨ͡Β௨৴Ωϟϯηϧͨ͠Γɺೖྗ଴ͪΛࢭΊͨΓ͢ Δɻ + subscribe() Observable + onNext() + onError() + onCompleted() + subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋
  29. + subscribe() Observable + onNext() + onError() + onCompleted() +

    subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋ ॲཧͷྲྀΕ
  30. + subscribe() Observable + onNext() + onError() + onCompleted() +

    subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋ subscribe(onNext: … ) ॲཧͷྲྀΕ
  31. + subscribe() Observable + onNext() + onError() + onCompleted() +

    subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋ subscribe(onNext: … ) ΠϕϯτΛҾ਺ͷΫϩʔδϟͰ଴ͪड͚Δ PO/FYU lIFMMPz  PO/FYU l3Yz  PO/FYU l8PSMEz  ʜ PO$PNQMFUFE ॲཧͷྲྀΕ
  32. + subscribe() Observable + onNext() + onError() + onCompleted() +

    subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋ subscribe(onNext: … ) dispose() ΠϕϯτΛҾ਺ͷΫϩʔδϟͰ଴ͪड͚Δ ॲཧͷྲྀΕ
  33. + subscribe() Observable + onNext() + onError() + onCompleted() +

    subscribe() Subject ܧঝ + dispose() Disposable subscribe() ͷ໭Γ஋ subscribe(onNext: … ) dispose() ΠϕϯτΛҾ਺ͷΫϩʔδϟͰ଴ͪड͚Δ ॲཧΛࢭΊͨ͘ͳͬͨΒEJTQPTFΛݺͿ ॲཧͷྲྀΕ
  34. (x, y) (x2, y2) (x3, y3) ྫɿλονΠϕϯτͷ؂ࢹ Observable<Point>) ࣌ؒͷྲྀΕ (x4,

    y4) TVCTDSJCF EJTQPTF EJTQPTFE (x2, y2) (x3, y3) Disposable.dispose()
  35. DisposeBag disposeΛ͍͍ͪͪ͢Δͷ͸ΊΜͲ͍͘͞ɻ ͦΜͳͱ͖͸DisposeBagɻ

  36. DisposeBag ը໘ͳͲɺ؂ࢹݩΠϯελϯε͕ࢮΜͩΒࣗಈͰͥΜ Ϳdisposeͯ͠΄͍࣌͠ʹ࢖͑ΔศརΫϥεɻ DisposeBagΠϯελϯεʹಥͬࠐΜͰ͓͘ͱɺ disposeBag͕ղ์͞ΕΔ࣌ʹ·ͱΊͯdisposeBagͷ தͷdisposableΛdisposeͯ͘͠ΕΔɻ ˠ3Yඪ४Ͱ͸ͳ͍Ͱ͕͢ΊͪΌͪ͘Ό࢖͍·͢ɻ ɹͱΓ͋͑ͣ%JTQPTF#BH࡞ͬͯ์ΓࠐΜͰ͓͚͹͍͍ͱࢥ͏ɻ

  37. (x, y) (x2, y2) (x3, y3) ྫɿλονΠϕϯτͷ؂ࢹ Observable<Point>) ࣌ؒͷྲྀΕ (x4,

    y4) TVCTDSJCF EJTQPTF EJTQPTFE (x2, y2) (x3, y3) EJTQPTFE CZEJTQPTF#BH Subscibe ॲཧ DisposeBag JOJU EFJOJU View %JTQPTBCMFΛ %JTQPTF#BHͷ தʹೖΕΔɻ %JTQPTF#BH͸ ഁغ͞ΕΔͱ தͷ%JTQPTBCMFΛ EJTQPTF͢Δɻ
  38. IUUQTHJUIVCDPNFDPPQOFUSYTXJGUCFHJOOFSCMPCNBTUFS3Y4XJGU4BNQMF3Y4XJGU4BNQMF 6*4BNQMF7JFX$POUSPMMFSTXJGU DisposeBagͷར༻ྫ ˡ6*7JFX$POUSPMMFSͷ ϑΟʔϧυʹEJTQPTF#BHΛஔ͍͓ͯ͘
 ˠը໘͕ดͨ͡Β6*7JFX$POUSPMMFS͕ࢮ͵ɻ ˠ6*7JFX$POUSPMMFS͕ࢮΜͩΒ%JTQPTF#BH΋ࢮ͵ɻ ˠ%JTQPTF#BH͕ࢮΜͩΒඥͮ͘EJTQPTBCMF͕ ɹEJTQPTF ͞ΕΔɻ

  39. ΦϖϨʔλ(Operator) Rxʹ͸ Observable, SubjectͰ࡞ͬͨετϦʔϜΛૢ ࡞͢Δػೳ͕ఏڙ͞Ε͍ͯ·͢ɻ ετϦʔϜ(=Observable)Λม׵ɾ߹੒ɾੜ੒͢Δૢ ࡞ͷ͜ͱΛʮΦϖϨʔλʯͱݺͼ·͢ɻ

  40. ετϦʔϜΛ࡞Δ ̍ … Subject Ϋϥε͔Β࡞Δ ̎ … from(), of(), just()

    ͳͲͰ೚ҙͷ഑ྻɾ஋Λ ม׵ͯ͠࡞Δ ̏ … Observable.create() Ͱ೚ҙͷॲཧ͔Β࡞Δ
  41. PublishSubject<T> completed ࣌ؒͷྲྀΕ TVCTDSJCF TVCTDSJCF

  42. 10 Observable.just(10) completed σʔλετϦʔϜͷྲྀΕ just( ) ετϦʔϜม׵

  43. “a” Observable.of(“a”, ”b”, ’c”, ”d”, “e”) completed σʔλετϦʔϜͷྲྀΕ of( ,

    , , , ) ετϦʔϜม׵ “b” “c” “d” “e”
  44. 1 Observable.from([1, 3, 5, 7, 9]) completed σʔλετϦʔϜͷྲྀΕ from([ ,

    , , , ]) ετϦʔϜม׵ 3 5 7 9
  45. Observable.error(MyError()) σʔλετϦʔϜͷྲྀΕ error( ) ετϦʔϜม׵ myError

  46. 1 Observable.create(೚ҙͷॲཧ) completed σʔλετϦʔϜͷྲྀΕ create(೚ҙͷॲཧ) ετϦʔϜม׵ 3 5 7 9

  47. map: ετϦʔϜΛม׵͢Δ map(_:((T) -> R)) -> Observable<R> ೚ҙͷܕɾ஋ͷετϦʔϜΛՃ޻ͯ͠ผͷܕɾ஋ͷετϦʔ Ϝʹม׵͠·͢ɻ

  48. filter: ετϦʔϜΛϑΟϧλ͢Δ filter(_:((T) -> Bool)) -> Observable<T> ྲྀΕ͖ͯͨετϦʔϜΛҾ਺ͷؔ਺Ͱॱ൪ʹॲཧ͠ɺ ݁Ռ͕true ʹͳΔσʔλ͚ͩͷετϦʔϜʹม׵͠·͢ɻ

  49. flatMap: ετϦʔϜΛม׵͢ Δ flatMap(_:((T) -> Observable<R>)) -> Observable<R> ೚ҙͷܕɾ஋ͷετϦʔϜΛՃ޻ͯ͠ผͷܕɾ஋ͷετϦʔ Ϝʹม׵͠·͢ɻmapͱ΄΅ಉ͡Ͱ͕͢ɺΫϩʔδϟͷฦΓ

    ஋͕Observableʹͳ͍ͬͯΔ఺͕ҟͳΓ·͢ɻ
  50. 1 completed 2 3 flatMap({x in Observable.of(x, x*10)}) 1 completed

    2 3 10 20 30 completed completed completed 1 completed 2 3 10 20 30
  51. filter, map, flatMap ͷྫ

  52. map ͱ flatMap ͷ࢖͍෼͚ map … ಉظతʹॲཧͰ͖Δσʔλม׵ʹ࢖͍·͢ɻ ྫɿStringܕ -> URLܕɺInt

    ܕΛॱ൪ʹܭࢉͯ͠ม׵͢Δ flatMap … ඇಉظॲཧͳͲɺผͷετϦʔϜΛ࢖ͬͯม׵͢Δ ࣌ʹ࢖͍·͢ɻ ྫɿtwitterͷπΠʔτIDετϦʔϜΛflatMapͯ͠ɺॱ൪ʹAPI Λୟ͍ͯ಺༰Λऔಘͯ͠λΠϜϥΠϯදࣔ͢Δ
  53. map ͱ subscribe ͷ࢖͍෼͚ ʢ؆୯ͳઆ໌ʣ ͲͪΒͰ΋onNext ʹ͍ͭͯॲཧ͕ग़དྷ·͕͢ɺ subscribe()͸ܨ͍ͩετϦʔϜΛಈ͔࢝͠ΊΔͱ͍͏େࣄͳ໾ׂ͕͋Γ·͢ɻ (ετϦʔϜม׵ͷऴ୺) subscribe()

    ͸ετϦʔϜม׵Ͱͳ͘ετϦʔϜ࣮ߦʹͳΔͨΊɺObservable Ͱͳ͘DisposableΛฦ͠·͢ɻ͜ͷͨΊmapͱҧ͍͏͠ΖʹετϦʔϜΛͭͳ ͛Δ͜ͱ͕Ͱ͖·ͤΜɻ
  54. 1 completed σʔλετϦʔϜͷྲྀΕ Observable.from([1, 2, 3, 4, 5]) ετϦʔϜม׵ 2

    3 4 5 filter({ x in x % 2 == 1}) 1 completed 3 5 map({ x in “v\(x)”) “v1” completed “v3” “v5” TVCTDSJCF “v1” completed “v3” “v5”
  55. ଞʹ΋ ศརͳΦϖϨʔλ͕ ͨ͘͞Μ͋Γ·͢ ࢀߟɿ http://reactivex.io/documentation/operators.html http://rxmarbles.com/

  56. ศརͳΦϖϨʔλͷҰྫ • zip, merge, combineLatest … 
 ෳ਺ͷετϦʔϜΛฒྻʹಈ͔ͯ̍ͭ͠ͷετϦʔϜʹ·ͱΊΔɻ • catchError

    …
 Τϥʔ͕ൃੜͨ͠ͱ͖ʹϦΧόϦॲཧΛͯ͠onNext ʹม׵͢Δɻ࠶౓ΤϥʔΛ౤͛Δ(throw)͜ͱͰɺผͷΤ ϥʔʹม׵͢Δ͜ͱ΋Ͱ͖Δ • distinctUntilChanged …
 ॏෳআ֎ɻετϦʔϜதʹมߋ͕͋ͬͨͱ͖͚ͩ௨஌͢Δ • throttle, debounce …
 ࿈ଧ๷ࢭʹ࢖͑ΔϑΟϧλɻσʔλΛड͚औͬͨΒҰఆ࣌ؒؒΛ։͚ͳ͍ͱ͕࣍ൃՐ͠ͳͨ͘͠Γ͢Δ • toArray … 
 ഑ྻʹ·ͱΊΔɻcompleted·Ͱ଴ͬͯ̍ͭͷ഑ྻʹม׵͢Δ • groupBy …
 ετϦʔϜͷσʔλΛ޷͖ͳ৚݅ͰάϧʔϓԽ͢Δ
  57. Try Rx!

  58. RxSwift/RxCocoa ͷ Πϯετʔϧ ᶃ CocoaPods → Podfile: ᶄ pod install

    ᶅ .swift ϑΝΠϧͰimport ※Carthage / Swift Package Manager ʹ΋ରԠͯ͠·͢ɻ https://github.com/ReactiveX/RxSwift 3Y$PDPBʹ͍ͭͯ͸ޙड़ ·ͨ͸
  59. Hello, Rx world ˠ

  60. Hello, Rx world2 ˠ

  61. Hello, Rx world3 ˣ

  62. RxCocoa ʹ͍ͭͯ RxSwift ͷαϒηοτతͳϥΠϒϥϦͰ͢ɻ RxSwift ͕७ਮͳ Rx ࣮૷ͰɺRxCocoa ͸ iOS/Mac։ൃʹศརͳ෇ଐΫϥεɾ֦ு

    Λఏڙ͍ͯ͠·͢ɻ RxCocoa Λ࢖͏ʹ͸ RxSwift ͱ͸ผʹϥΠϒϥϦΠϯετʔϧ͕ඞཁʹͳΓ·͢ɻ > pod ‘RxCocoa' Ͱ pod install ͯ͠ɺswiftίʔυ಺Ͱ import RxCocoa Λॻ͍͓ͯ͘ͱ࢖͑·͢ɻ
  63. RxCocoa ͕ఏڙ͢Δػೳͷྫ

  64. UIKit ఏڙΫϥεͷ rx Խ UIView, URLSession ͳͲUIKit,͕ఏڙ͢ΔΫϥεͷϓϩύςΟɾΠϕϯτ ΛrxԽͯ͠ɺObservableΠϯελϯεͱͷ૬ޓόΠϯυΛՄೳʹ͢Δɻ ྫɿ -

    ਺ࣈΛςΩετೖྗͨ͠Βϥϕϧʹܭࢉ݁ՌΛදࣔ͢Δɻ - ϘλϯΛԡͨ͠ΒAPI௨৴ͯ͠ɺAPI࣮ߦ݁ՌΛϥϕϧʹදࣔ͢Δɻ - URLSession ͷAPI௨৴݁ՌJSONΛ੔ܗͯ͠ϓϩϑΟʔϧը໘ʹදࣔ
  65. ஌͓ͬͯ͘ͱྑ͍͔΋ɻ • RxAlamofire ͳͲ୳ͤ͹ઌਓ͕RxԽͯ͘͠ ΕͯΔ΋ͷɺެ։͞ΕͯΔίʔυ͕݁ߏ͋ Γ·͢ɻ

  66. ·ͱΊ

  67. ·ͱΊ • σʔλͷ΍ΓऔΓΛετϦʔϜͱͯ͠ߟ͑Α͏ • ͱΓ͋͑ͣRxͷετϦʔϜ(Observable)ʹͰ͖ͨ Βͬͪ͜ͷ΋ͷɻͲ͏Ճ޻ͯ͠໨తͷܗࣜʹ͢Δ ͔Λߟ͑Α͏ɻ • RxΛۃΊͨΒϩδοΫ͕γϯϓϧʹ෭࡞༻ͳ͘ɺ εϚʔτʹॻ͚ΔΑ͏ʹͳΔɻඇಉظॲཧ΋ා͘

    ͳ͍ʢ͸ͣʣ
  68. ͍͞͝ʹ • tech vein Ͱ͸͜ΜͳΞϓϦΤϯδχΞɺ
 ϑϦʔϥϯεɾύʔτφʔ༷Λืू͍ͯ͠·͢ɻ • RxSwift, RxJava Λ࢖͍͍ͨ

    • MVVMɺ CleanArchitectureɺ DI Λ׆༻ͨ͠ઃܭʹڵຯ͕͋Δ ڵຯ͕͋Δํɺͪΐͬͱ࿩Λฉ͍ͯΈ͍ͨํ
 ͨͩ3Yͷ࿩Λ΋ͬͱฉ͖͍ͨํ΋
 ͥͻ͓੠͕͚Լ͍͞ʂ
  69. ࢀߟ • ࠓճͷαϯϓϧίʔυஔ͖৔ɹʴ RxCocoa Λ࢖ͬͨ؆୯ͳΞϓ Ϧ • GitHub:
 https://github.com/ecoopnet/rxswift-beginner •

    ࢀߟهࣄ • Կͱͳ͘RxJavaΛ࢖ͬͯΔ͚Ͳਖ਼௚Α͘෼͔ͬͯͳ͍ਓ͕ಡ Ήͱྑͦ͞͏ͳهࣄɾجૅฤ
 https://qiita.com/k-mats/items/4d374460a3f6284dd09f
  70. ͕࣌ؒ͋Ε͹αϯϓϧΞϓϦσϞ

  71. ͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠

  72. Driver ͷ࢖͍ํ͸ Observable ͱ΄΅ಉ͡

  73. Driver ͷ࢖͍ํ͸ Observable ͱ΄΅ಉ͡ʁ →Τϥʔॲཧ͕ཁΒͳ͍౳ͷࡉ͔͍ҧ͍͸͋Δ

  74. Driver (ิ଍) ۩ମతʹ͸ observable.asDriver(onErrorJustReturn: “”) ͱ͢Δͱ - UIεϨουͰॲཧɿ .observeOn(MainScheduler.instance) -

    Cold -> Hot ม׵ɿ .share(replay:1) - Τϥʔ࣌ʹ؂ࢹ͕ࢭ·ΔͷΛ๷͙ͨΊͷϦΧόϦॲཧɿ .catchError({ _ in “” }) Λ·ͱΊͯ΍ͬͯ͘ΕΔΑ͏ʹͳΓ·͢ɻ ˎ