ReactorKit으로 단방향 반응형 앱 만들기
-
Upload
suyeol-jeon -
Category
Software
-
view
238 -
download
6
Transcript of ReactorKit으로 단방향 반응형 앱 만들기
• StyleShare, Inc.• Open Source Lover• Then• URLNavigator• RxSwift• ObjectMapper
let swift(17)
Why?
Why?1. Massive View Controller
•
•
Why?1. Massive View Controller
•
•
2. RxSwift is Awesome
•
•
Why? :
1. Massive View Controller
2. RxSwift
Why? - Problems RxSwift ?
• Rx + MVC?
• Rx + MVVM?
⚠ : .
Why? - ProblemsCyclic Data Dependencies
•
• :
• nextURL
Why? - ProblemsCyclic Data Dependencies
• : BehaviorSubject
• BehaviorSubject(=Variable)
• RxSwift
Why? :
1. Massive View Controller
2. RxSwift
Why? :
1. Massive View Controller
2. RxSwift
3.
let swift(17)
ReactorKit
ReactorKit1. Massive View Controller . ✅
•
•
ReactorKit2. RxSwift . ✅
• ReactorKit RxSwift
• RxSwift
ReactorKit3. . ✅
•
• reduce()
•
ReactorKit...
• ( )
•
• CocoaPods 8800 / 280
ReactorKit...
• ( )
•
• CocoaPods 8800 / 280
Basic Concept
Basic Concept
• Reactor
• Reactor
• , , View
Basic Concept
protocol View { associatedtype Reactor
var disposeBag: DisposeBag
// self.reactor func bind(reactor: Reactor) }
Basic Concept
protocol StoryboardView { associatedtype Reactor
var disposeBag: DisposeBag
// func bind(reactor: Reactor) }
// Storyboard
Basic Concept
• View Action
• View
• View Reactor
Basic Concept
protocol Reactor { associatedtype Action associatedtype Mutation associatedtype State
var initialState: State }
Basic Concept
Basic Concept
RxSwift
Data Flow
Data Flow
Data FlowAction State
• State
• Action State Mutation
• Mutation State /
• Mutation View
Data Flow
Data Flowclass ProfileViewReactor: Reactor { enum Action { case follow // }
struct State { var isFollowing: Bool // } }
Data Flowclass ProfileViewReactor: Reactor { enum Action { case follow // }
struct State { var isFollowing: Bool // } }
API State
Data Flowclass ProfileViewReactor: Reactor { enum Action { case follow // }
enum Mutation { case setFollowing(Bool) // }
struct State { var isFollowing: Bool // } }
Data Flow(Action) -> Observable<Mutation>
(State, Mutation) -> State
Data Flow
Data Flow
Data Flow
Action.follow
Data FlowAction.follow
Data Flow
UserService.follow()
Data Flow
UserService
Data Flow
Observable<Bool>
Data Flow
Data Flow
Mutation.setFollowing(true)
Data Flow
Mutation.setFollowing(true)
Data Flow
isFollowing = true
Data Flow
Data Flow
let swift(17)
Example - Live Coding
CommunitySwift Korea Slack: #reactorkit
• http://slack.swiftkorea.org/
RxSwift Slack: #reactorkit ( )
• http://rxswift-slack.herokuapp.com/
http://reactorkit.io