订阅
//第1次订阅
self.model.userName.asObservable().subscribe {
print("第1次订阅:", $0)
}.disposed(by: disposeBag)
//修改value值
self.model.userName.value = "333"
//第2次订阅
self.model.userSex.asObservable().subscribe {
print("第2次订阅:", $0)
}.disposed(by: disposeBag)
//修改value值
self.model.userSex.value = "444"
取消订阅
var disposeBag = DisposeBag()
let disBag = DisposeBag()
viewModel.disposeBag = disBag
网友评论