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

ReactorKit으로 단방향 반응형 앱 만들기

Suyeol Jeon
September 24, 2017

ReactorKit으로 단방향 반응형 앱 만들기

Suyeol Jeon

September 24, 2017
Tweet

More Decks by Suyeol Jeon

Other Decks in Programming

Transcript

  1. ੹ࣻৌ • StyleShare, Inc. • Open Source Lover • Then

    • URLNavigator • RxSwift • ObjectMapper
  2. Why? 1. Massive View Controller • ੉޷ ݆਷ ࢎۈٜ੉ ҕхೞח

    ޙઁ • ೧Ѿೞӝ ਤೠ ৈ۞ ࢸ҅ ಁఢٜ੉ ઓ੤
  3. Why? 1. Massive View Controller • ੉޷ ݆਷ ࢎۈٜ੉ ҕхೞח

    ޙઁ • ೧Ѿೞӝ ਤೠ ৈ۞ ࢸ҅ ಁఢٜ੉ ઓ੤ 2. RxSwift is Awesome • ࠺زӝ ௏٘ܳ рѾೞѱ ࢎਊೡ ࣻ ੓਺ • য۵૑݅ ੜ ॳݶ ҭ੢൤ ౵ਕಽೠ ӝࣿ
  4. Why? - Problems ਬݺೠ ࢸ҅ ಁఢী RxSwiftܳ ࠢৈࠅө? • Rx

    + MVC? • Rx + MVVM? ⚠ ҕా੸ੋ ޙઁ: ࢚క ҙܻо ݒ਋ য۵׮.
  5. Why? - Problems Cyclic Data Dependencies • ׮਺ ੘সਸ ਤ೧

    ੉੹ ੘স੄ Ѿҗо ೙ਃ • ৘द: ইې۽ झ௼܀ೞৈ ׮਺ ಕ੉૑ ۽٘ • ׮਺ ਃ୒ী ੉੹ ਃ୒ Ѿҗ੄ nextURL ೙ਃ
  6. Why? - Problems Cyclic Data Dependencies • औѱ ೧Ѿೞח ߑߨ:

    BehaviorSubject ࢎਊ • BehaviorSubject(=Variable)ܳ թߊ • RxSwiftח ࢶ঱੸ਵ۽ ੘ࢿೞח Ѫਸ ӂ੢
  7. Why? ೞҊर਷ Ѫ: 1. Massive View Controllerܳ ೖೞݶࢲ 2. RxSwift੄

    ੢੼ਸ ݽف ஂೞҊ र׮ 3. ӒܻҊ ࢚క ҙܻо एਛਵݶ જѷ׮
  8. ReactorKit 1. Massive View Controllerܳ ೖೞҊ र׮. ✅ • ࠭৬

    ۽૒੄ ҙबࢎ ܻ࠙ • ࠭ ஶ౟܀۞о ױࣽ೧૗
  9. ReactorKit 2. RxSwift੄ ੢੼ਸ ݽف ஂೞҊ र׮. ✅ • ReactorKit਷

    RxSwiftܳ ӝ߈ਵ۽ ೣ • ݽٚ RxSwift ӝמਸ ࢎਊ оמ
  10. ReactorKit 3. ࢚క ҙܻо एਛਵݶ જѷ׮. ✅ • ױߑೱ ؘ੉ఠ

    ൒ܴ • ઺р ࢚కܳ reduce() ೣࣻ۽ ҙܻ • ࢚క ҙܻо рѾ೧૗
  11. ReactorKit ӒܻҊ... • ౠ੿ ӝמী ࠗ࠙੸ ੸ਊ оמ (੘ѱ द੘)

    • పझ౟ܳ ਤೠ بҳܳ ੗୓੸ਵ۽ ૑ਗ • CocoaPods ӝળ ࢸ஖ 8800ഥ / জ 280ѐ
  12. ReactorKit ӒܻҊ... • ౠ੿ ӝמী ࠗ࠙੸ ੸ਊ оמ (੘ѱ द੘)

    • పझ౟ܳ ਤೠ بҳܳ ੗୓੸ਵ۽ ૑ਗ • CocoaPods ӝળ ࢸ஖ 8800ഥ / জ 280ѐ
  13. Basic Concept • ࢎਊ੗ ੑ۱ਸ ߉ইࢲ Reactorী ੹׳ • Reactor۽ࠗఠ

    ߉਷ ࢚కܳ ۪؊݂ • ࠭ ஶ౟܀۞, ࣄ, ஶ౟܀ ١ਸ ݽف View۽ ஂә
  14. Basic Concept protocol View { associatedtype Reactor var disposeBag: DisposeBag

    // self.reactorо ߄Շݶ ഐ୹ؽ func bind(reactor: Reactor) }
  15. Basic Concept protocol StoryboardView { associatedtype Reactor var disposeBag: DisposeBag

    // ࠭о ۽٘غݶ ഐ୹ؽ func bind(reactor: Reactor) } // Storyboardܳ ࢎਊೞח ҃਋
  16. Basic Concept • Viewীࢲ ੹׳߉਷ Actionী ٮۄ ۽૒ ࣻ೯ •

    ࢚కܳ ҙܻೞҊ ࢚కо ߸҃غݶ Viewী ੹׳ • ؀ࠗ࠙੄ Viewח ؀਽غח Reactorܳ о૗
  17. Data Flow Action੉ Stateܳ ߄۽ ߸҃ೞ૑ח ঋ਺ • ࠺زӝ ఋ੐ী

    Stateо ߸҃غח ҃਋о ੓਺ • Actionҗ State ࢎ੉ী Mutationਸ ىࢲ ࠺ز ӝ ୊ܻ • Mutation਷ Stateܳ ߸҃ೞח ݺ۸/੘স ױਤ • Mutation਷ Viewী ֢୹غ૑ ঋ਺
  18. Data Flow class ProfileViewReactor: Reactor { enum Action { case

    follow // ࢎਊ੗ ੑ۱ } struct State { var isFollowing: Bool // ࠭ ࢚క } }
  19. Data Flow class ProfileViewReactor: Reactor { enum Action { case

    follow // ࢎਊ੗ ੑ۱ } struct State { var isFollowing: Bool // ࠭ ࢚క } } ࢎਊ੗ܳ ౹۽਋ೞח API ਃ୒ റ Stateо ߄Շযঠ ೣ
  20. Data Flow class ProfileViewReactor: Reactor { enum Action { case

    follow // ࢎਊ੗ ੑ۱ } enum Mutation { case setFollowing(Bool) // ࢚క ߸҃ } struct State { var isFollowing: Bool // ࠭ ࢚క } }
  21. Community Swift Korea Slack: #reactorkit ଻օ • http://slack.swiftkorea.org/ RxSwift Slack:

    #reactorkit ଻օ (৔য) • http://rxswift-slack.herokuapp.com/