Manually disposing a DisposeBag in RxSwift

守給你的承諾、 提交于 2019-12-10 12:53:23

问题


I want to cancel a request and one of the ways is to manually remove the disposable bag.

.addDisposableTo(disposeBag)

As I have the disposeBag object, is there a good way to cancel the request other than that I mentioned above?


回答1:


You have to just change reference to your disposeBag object. Make it nil or assign new object to disposeBag.

All request will be cancelled.




回答2:


Another option, besides deallocating a DisposeBag, is to use CompositeDisposable, which has an explicit dispose method.



来源:https://stackoverflow.com/questions/38969328/manually-disposing-a-disposebag-in-rxswift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!