在 model 中监听属性变化, 然后通过发射信号
class Item: Convertible { /** 监听收藏属性变化, 通知cell的收藏状态变更*/ var rx_favoritiesVar: BehaviorRelay<Bool> = BehaviorRelay(value: false) var favoritesStatus: Bool = false { willSet { rx_favoritiesVar.accept(newValue) } } required init() { } }
var item: Item? { didSet { item?.rx_favoritiesVar.asObservable().subscribe(onNext: {[weak self] (isCollect) in }).disposed(by: self.bag) } }