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

今日こそ理解するHot変換@社内RxSwift勉強会

 今日こそ理解するHot変換@社内RxSwift勉強会

今日こそ理解するHot変換

ukitaka

July 18, 2016
Tweet

More Decks by ukitaka

Other Decks in Programming

Transcript

  1. !?

  2. (෮श)Hotʹؔ࿈͢ΔΦϖϨʔλ Hotʹؔ࿈͢ΔΦϖϨʔλ͸ҎԼͷΈɻ ͜ΕΒ͕ಛʹݺ͹Εͯͳ͚Ε͹Hotʹม׵͞ΕΔ͜ͱ΋ͳ͍ɻ • multicast / publish • replay /

    replayAll • connect / refCount • share / shareReplay • shareReplayLatestWhileConnected ؚΈͷ͋Δݴ͍ํ
  3. ConnectableObservable·ͱΊ • ColdͳObservableʹରͯ͠ɺmulticast() / publish() / replay(bufferSize:) / replayAll() Λݺͼ

    ग़͢͜ͱͰ ConnectableObservableʹม׵Ͱ͖ Δɻ • ConnectableObservableʹରͯ͠connect()Λݺͼ ग़͢͜ͱͰHotͳObservableʹม׵͕׬ྃ͢Δɻ
  4. shareReplay(bufferSize:) • ໊લͷ௨Γɺshare + replay • share = publish +

    refCount • shareReplay = publish + refCount + replay • ʮHot͕ͩɺ࠷ॳʹsubscribe͞ΕΔ·Ͱಈ࡞͠ͳ ͍ʯΛकΓͭͭࢦఆ͞Εͨݸ਺͚ͩ஋Λreplay͢ Δ
  5. shareReplayLatestWhileConnected() • ໊લ͕ΊͬͪΌ௕͍ • ͜Μͳͷ࢖͏ػձ͋Δͷʁͱࢥ͏͔΋͠Εͳ͍͕ɺ RxSwift(RxCocoa)Ͱఏڙ͞Ε͍ͯΔ Driver͸σϑΥϧτͰ͜Εͱಉ ͡ڍಈΛ͢ΔɻͳͷͰڍಈ͸ཧղ͓ͯ͘͠΂͖ɻ • ShareReplay1

    ͱͷҧ͍͸ɺconnect தͰͳ͍ͱ࠷ޙͷ஋͕औΕͳ͍ ͜ͱɻͭ·Γ1౓ .Completed ͕ྲྀΕͨΒͦͷ͋ͱʹ͸replay͞Ε ͣɺ.Completed ͔͠ྲྀΕͯ͜ͳ͍ɻ • ڍಈͷৄࡉͳྫ͸Driverͷͱ͖ʹઆ໌͢ΔͷͰ͜͜Ͱ͸ׂѪɻ