Search code examples
androidandroid-workmanager

WorkManager: Do you need to manually dispose of Observables in a Worker?


Lets say in your doWork() method you have an Observable that emits the progress of a download, do you need to manually dispose of this Observable to avoid memory leaks? And thus use RxWorker?

According to this Do I have to unsubscribe from completed observable? "On the JVM, an anonymous inner class maintains a reference to the outer class." But in this case our outer class is not an activity or fragment, it's a Worker. So would it leak?


Solution

  • Use RxWorker and that will take care of disposing for you.