When to call dispose and clear on CompositeDisposable

后端 未结 3 1090
清酒与你
清酒与你 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:30

    You're right, you can save yourself from creating a new CompositeDisposable for each time the corresponding view is created, but instead treat a CompositeDisposable as a single instance tied to the onCreate/onDestroy lifecycle methods and treat aggregated disposables as part of the fragment view calling clear in onDestroyView.

提交回复
热议问题