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

Getting Started Combine

Getting Started Combine

Combine をはじめよう

Mobile Act ONLINE #1
https://mobileact.connpass.com/event/181370/

ブログ記事
https://usami-k.hatenablog.com/entry/2020/07/23/214102

USAMI Kosuke

July 22, 2020
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. Combine ͱ͸ • Reactive Programming ͷϑϨʔϜϫʔΫ • RxSwift ΍ ReactiveSwift

    ͱಉྨ • ඇಉظॲཧΛॊೈʹهड़Ͱ͖Δ • Ϟσϧͱ UI ͷόΠϯσΟϯάΛهड़Ͱ͖Δ 4/23
  2. ࡢ೥ൃද͞Εͯ࿩୊ʹͳͬͨ • Combine ͸ࡢ೥ͷ WWDC19 Ͱൃද͞Εͨ • ࿩୊ʹ͸ͳͬͨ΋ͷͷɺiOS 13 ͰͷΈ࢖༻Մೳ

    • → ࣮ࡍͷ։ൃʹద༻͠ʹ͔ͬͨ͘ • ͔͠͠ɺ1೥ͨͬͨݱࡏɺঢ়گ͸ҟͳΔ 5/23
  3. iOS ΞϓϦͷ։ൃࣄ৘ • ཧ૝తʹ͸࠷৽ OS ͷΈΛαϙʔτ͍ͨ͠ • ͔࣮͠͠ࡍ͸ɺগ͠લͷ OS ͷαϙʔτΛཁ๬͞ΕΔ

    • ࠷৽ OS ͱͦͷ1ͭલͷ OS ·Ͱͷαϙʔτ͕ݱ࣮࿏ઢ • iOS 14 ϦϦʔεޙ͸ iOS 13 ʙ 14 ରԠ͸ݱ࣮త 6/23
  4. ଞͷϑϨʔϜϫʔΫͱͷൺֱ • طʹ Reactive Programming ϑϨʔϜϫʔΫ͸͋Δ • RxSwift : ReactiveX

    ܥ • ReactiveSwift : Swift ͷྑ͞Λ׆͔͍ͯ͠Δ • Combine ͷར఺ • αʔυύʔςΟ੡Ͱͳ͘ඪ४Ͱ͋Δ 8/23
  5. ͳͥɺ͍· Combine Λ͸͡ΊΔͷ͔ • λΠϛϯά͕ͪΐ͏Ͳྑ͍ • iOS 13 Ҏ߱Λର৅ͱ͢Δ͜ͱ͕ݱ࣮తʹՄೳʹͳ͖ͬͯͨ •

    ͋Δఔ౓੒ख़ͨ͠ϑϨʔϜϫʔΫͰ͋Γ҆৺ͯ͠࢖͑Δ • ඪ४ϑϨʔϜϫʔΫͳͷͰαʔυύʔςΟґଘ͠ͳ͍ 9/23
  6. UIKit / SwiftUI • Combine ͸ͲͪΒͱ΋૊Έ߹ΘͤΒΕΔ൚༻తͳ΋ͷ • ࠓ͸ UIKit ͷ૊Έ߹Θ͕ͤݱ࣮త

    • SwiftUI ͸ iOS 13 ରԠ͕ඞཁͳঢ়گͰ͸ػೳෆ଍ؾຯ • iOS 14 Ͱ͸େ͖͘վળ͍ͯ͠Δ 10/23
  7. Combine Λֶ΅͏ • WWDC19 ͷηογϣϯ • ࠓͳΒ೔ຊޠࣈນ΋͋Δ • ༷ʑͳਓ͕هࣄ΍ॻ੶Λॻ͍͍ͯΔ •

    ࡢ೥ొ৔Ҏ߱Ͱ஫໨౓͕ߴ͍͜ͱ͕෼͔Δ • ଞͷϑϨʔϜϫʔΫͱͷ༻ޠͷҧ͍ʹ͸஫ҙ 12/23
  8. Combine Λ࢖͏ҙຯ • ҎԼͷΑ͏ͳඇಉظॲཧΛ͢΂ͯ Combine Ͱॻ͚Δ • Target / Action

    • Notification Center • URL Session • Key-Value Observing • Callback 18/23
  9. ิ଍ : UIControl ͷରԠ • UIButton ͳͲͷ Publisher ͕ඪ४Ͱ͸༻ҙ͞Ε͍ͯͳ͍ •

    ͜Ε͸ඪ४Ͱཉ͔ͬͨ͠ͱ͜Ζ͕ͩɾɾɾ • ΧελϜ Publisher Λ࣮૷ͯ͠ରԠ͢Δ • ࢀߟ : ʲSwiftʳCustom PublisherΛ࡞੒ͯ͠Combineϑ ϨʔϜϫʔΫͷಈ͖ΛֶͿ - @shiz ͞Μͷ Qiita هࣄ 21/23
  10. ิ଍ : UIControl ͷରԠ ΧελϜ Publisher Λ࣮૷͢Ε͹ҎԼͷΑ͏ͳ͜ͱ͕Ͱ͖Δ let cancellable =

    button .publisher(for: ...) .sink(receiveValue: { /* Πϕϯτॲཧ */ }) 22/23