[英]Observer still receiving events after being disposed in cell RxSwift
I'm using RxSwift for form handling in collection view and table view. 我正在使用RxSwift在集合视图和表视图中进行表单处理。 I am facing an issue. 我面临一个问题。
I have a single selection list component and I am creating DisposeBag
every time while configuring to remove all previous subscribers. 我只有一个选择列表组件,并且每次配置为删除所有先前的订户时都在创建DisposeBag
。 onDisposed
method is called for both but I still receive duplicate onNext
events. onDisposed
都调用了onDisposed
方法,但是我仍然收到重复的onNext
事件。 This works fine in that start but when I reload the collection view or the table view I am facing this issue. 从一开始就可以正常工作,但是当我重新加载集合视图或表视图时,我遇到了这个问题。 Please let me know is there something I am doing wrong or is this bug in library. 请让我知道我做错了什么或者是库中的这个错误。
var selectedIndex = Variable<Int?>(nil)
func configureRx(sender: RxRow<Int>) {
dateVarDisposable = DisposeBag()
selectedIndex
.asObservable()
.subscribe(onNext: {[weak self] (index) in
self?.selectRow(selectedIndex: index)
}, onDisposed: {
print("")
})
.addDisposableTo(disposableBag)
sender.dataVariable.asObservable()
.debug(self.stringTag, trimOutput: false)
.subscribe(onNext: { (sender) in
self.selectedIndex.value = sender
}, onDisposed: {
})
.addDisposableTo(disposableBag)
}
Check this: https://github.com/ReactiveX/RxSwift/issues/821 . 检查一下: https : //github.com/ReactiveX/RxSwift/issues/821 。 There's a special category for cells - reuseBag
有一个特殊的单元格类别- reuseBag
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.