我正在阅读有关输入输出 ViewModel 方法的博客: https ://medium.com/blablacar-tech/rxswift-mvvm-66827b8b3f10
完整代码:https ://gist.github.com/MartinMoizard
我只是对如何做到感到困惑
let greeting = validateSubject
.withLatestFrom(nameSubject)
.map { name in
return "Hello \(name)!"
}
.asDriver(onErrorJustReturn: ":-(")
https://gist.github.com/MartinMoizard/4d66528a9959cbbdefa6d50394d2bfb1
如果在https://gist.github.com/MartinMoizard/449be0d30920010210988f1773a2ca90中点击validateSubject是私有的, 则会触发
final class ButtonCell: UITableViewCell, SayHelloViewModelBindable {
@IBOutlet weak var validateButton: UIButton!
var disposeBag: DisposeBag?
override func prepareForReuse() {
super.prepareForReuse()
disposeBag = nil
}
func bind(to viewModel: SayHelloViewModel) {
let bag = DisposeBag()
validateButton.rx
.tap
.bind(to: viewModel.input.validate)
.disposed(by: bag)
disposeBag = bag
}
}
TIA