개요
- 복수 개의 뷰들간의 커뮤니케이션을 위해서 사용하는 delegate pattern 혹은 callback closure 에 익숙할 것이다.
- RxSwift 를 사용하면 Reactive Extension 도 고려할 수 있다.
- ReactorKit 에서는 Reactive Extension 를 추천한다.
- ReactorKit 에서 View 는 UIVC, UIView 등을 포함한다.
- 가장 일반적인 예시는 rx.tap 이다

코드 예시
ChatVC 가 MessageInputView 를 소유하고 있는 상황
- MessageInputView 에서 방출된 text 를 ChatVC 가 자신의 reactor.state 에 바인딩 (위 이미지 상황과 동일)
extension Reactive where Base: MessageInputView {
var sendButtonTap: ControlEvent<String> {
let source = base.sendButton.rx.tap.withLatestFrom(...)
return ControlEvent(events: source)
}
}
자료
GitHub - ReactorKit/ReactorKit: A library for reactive and unidirectional Swift applications