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?
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?
You have to just change reference to your disposeBag object. Make it nil or assign new object to disposeBag.
All request will be cancelled.
Another option, besides deallocating a DisposeBag
, is to use CompositeDisposable
, which has an explicit dispose
method.
CompositeDisposable
does not dispose on deinit. IT IS NOT A REPLACEMENT FOR A DisposeBag
. You should still add your CompositeDisposable
to another DisposeBag
or make sure you manually dispose of it on your deinit method. –
Riotous You just need to reinitialise the dispose bag reference:
disposeBag = .init()
© 2022 - 2024 — McMap. All rights reserved.