When to call dispose and clear on CompositeDisposable

后端 未结 3 1091
清酒与你
清酒与你 2020-12-29 18:02

My question can be a duplicate of How to use CompositeDisposable of RxJava 2? But asking to clear one more doubt. According to the accepted answer

// Using          


        
3条回答
  •  既然无缘
    2020-12-29 18:31

    Instead of using CompositeDisposable.dispose(), you can better use CompositeDisposable.clear() so you don't have to create a new CompositeDisposable: method documentation.

    clear() //Atomically clears the container, then disposes all the previously contained Disposables.
    
    dispose() //Dispose the resource, the operation should be idempotent.
    

提交回复
热议问题