Closed Thomvis closed 6 years ago
The warning is pretty clear: The created observable keeps a strong reference to {@code view}.
This seems to be the appropriate course of action:
I should stop keeping references to the observable
You should be holding the Disposable
returned from a subscription if anything, but there's very little reason to keep a reference to the Observable
itself.
You can use a CompositeSubscription
and add every subscription to it, then in onDestroy
call clear()
on it to release everything. check here https://www.youtube.com/watch?v=QdmkXL7XikQ
What they said. We give you a handle to the strong reference that you can dispose of in your lifecycle when it's no longer needed.
Many methods in RxBinding are documented with the following warning:
In addition to unsubscribing, I think you should also not have any strong reference to the created observable itself, since its OnSubscribe holds a reference to the view. This was not immediately apparent to me, but I do have to think about it because I regularly store the returned observable in a field (of the view model).
I'd be happy to hear what/if you think should be done:
Thanks!