androidkotlindisposable

Why you have to dispose a thing on CompositeDisposable in RxJava?


Sorry i am still newbie in android development. I wanted to understand why we have to dispose thing from CompositeDisposable? and why we have to use CompositeDisposable?


Solution

  • We have to dispose disposables from CompositeDisposable to stop the in progress requests when they are not required anymore. They should be cleared every time a user navigates to another activity from current activity or in cases in which the current activity is destroyed to cancel pending disposable requests and avoid memory leaks.