KEMBAR78
ReactorKit으로 단방향 반응형 앱 만들기 | PDF
letswift(17)
ReactorKit
ReactorKit
github.com/devxoul
• StyleShare, Inc.

• Open Source Lover

• Then

• URLNavigator

• RxSwift

• ObjectMapper
letswift(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? - Problems
Cyclic Data Dependencies

• 

• : 

• nextURL
Why? - Problems
Cyclic Data Dependencies

• : BehaviorSubject 

• BehaviorSubject(=Variable) 

• RxSwift
Why?
:

1. Massive View Controller 

2. RxSwift
Why?
:

1. Massive View Controller 

2. RxSwift 

3.
letswift(17)
ReactorKit
ReactorKit
1. Massive View Controller . ✅

• 

•
ReactorKit
2. RxSwift . ✅

• ReactorKit RxSwift 

• RxSwift
ReactorKit
3. . ✅

• 

• 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 Flow
Action State 

• State 

• Action State Mutation


• Mutation State / 

• Mutation View
Data Flow
Data Flow
class ProfileViewReactor: Reactor {
enum Action {
case follow //
}
struct State {
var isFollowing: Bool //
}
}
Data Flow
class ProfileViewReactor: Reactor {
enum Action {
case follow //
}
struct State {
var isFollowing: Bool //
}
}
API State
Data Flow
class 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 Flow
Action.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
letswift(17)
Example - Live Coding
Community
Swift Korea Slack: #reactorkit 

• http://slack.swiftkorea.org/

RxSwift Slack: #reactorkit ( )

• http://rxswift-slack.herokuapp.com/
http://reactorkit.io

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