我正在使用RxSwift 4.0并使用DTTableViewManager
1
lazy var mostRecent: TableTitleHeaderContainer = {
let container = TableTitleHeaderContainer(isHidden: true, title: "Title 1")
return container
}()
lazy var lastRecent: TableTitleHeaderContainer = {
let container = TableTitleHeaderContainer(isHidden: false, title: "Title 2")
return container
}()
模型代码
2
class TableTitleHeaderContainer {
var subject: PublishSubject<Void> = PublishSubject<Void>()
var isHidden: Bool
var title: String
var disposeBag = DisposeBag()
init(isHidden: Bool, title: String) {
self.isHidden = false
self.title = title
}
}
并使用模型
查看配置第3
extension TableTitleHeaderView: ModelTransfer {
func update(with model: TableTitleHeaderContainer) {
clearButton.isHidden = model.isHidden
clearButton.rx.tap
.bind(to: model.subject).disposed(by: disposeBag)
titleLabel.text = model.title
}
}
我想听一下Presenter中的按钮
4
mostRecent.subject.asObserver().subscribe(onNext: { [weak self] (_) in
print("Clear mostRecent")
}).disposed(by: disposeBag)
lastRecent().subject.asObserver().subscribe(onNext: { [weak self] (_) in
print("Clear lastRecent")
}).disposed(by: disposeBag)
但是在Presenter中使用模型订阅配置视图后没有调用? 有什么麻烦?