这是我的代码在这里:
class MapManager: NSObject {
let removeFenceTask = BehaviorRelay<String?>(value: nil)
override init() {
super.init()
removeFenceTask
.filter({ $0 != nil })
.debug("removeFenceTask", trimOutput: true)
.flatMap { (taskId: String?) -> Observable<TaskModel> in
guard let `taskId` = taskId, let provider = Application.shared.provider else { return Observable.just(TaskModel()) }
return provider.queryTaskDetail(taskId: taskId).asObservable()
}
.asObservable()
.subscribe(onNext: { [weak self] (taskModel) in
self?.removeFence(taskModel: taskModel)
}).disposed(by: rx.disposeBag)
}
}
func queryTasks(_ currentPage: Int, status: TaskStatus) -> Single<([TaskModel], Bool)> {
return requestObject(
.queryTasks(currentPage: currentPage, pageSize: 10, status: status), type: TaskModelWrapper.self)
.map({ (taskModelWrapper) -> ([TaskModel], Bool) in
let tasks = taskModelWrapper.data?.data ?? []
tasks.filter({ $0.taskStatus == .canceled || $0.taskStatus == .deliveryCompleted || $0.taskStatus == .taskCompleted || $0.taskStatus == .terminated })
.forEach { (taskModel) in
MapManager.shared.removeFenceTask.accept(taskModel.taskId)
}
return (tasks, taskModelWrapper.data?.isNoMoreDataShow ?? false)
})
}
最后我在成功完成2个事件后得到isDisposed
控制台:
2019-11-27 10:46:27.203:newFenceTask->已订阅
2019-11-27 10:46:27.203:removeFenceTask->已订阅
2019-11-27 10:46:27.204:removeFenceTask->事件next(Optional(“ 123”))
2019-11-27 10:46:27.207:removeFenceTask->事件next(Optional(“ 1908157SRZTT2DGF”))]]
2019-11-27 10:46:27.295:removeFenceTask-> isDisposed
问题:
为什么发生此isDisposed
?这是我的代码在这里:类MapManager:NSObject {让removeFenceTask = BehaviorRelay
您的rx.disposeBag
不被处分吗?