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
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.