Say I have a Flowable that is shared between different parts of an application.
In every fragment where I want to watch it, I convert it to LiveData s LiveDataReactiveStreams.fromPublisherto avoid leaks and crashes. Now I have a LiveData that wraps my Flowable.
Then I pass the LiveData to my ViewModel (in ViewModelFactory). As far as I understand, I can continue to use LiveData without worrying about leaks.
Now, instead of direct observation of LiveData, I have a desire to translate it back into Flowable using LiveDataReactiveStreams.toPublisherand Flowable.fromPublisherand instead subscribe to Flowable. Now it's Flowable, which wraps LiveData, which wraps Flowable
My question is: should I worry about unsubscribing from this stream? I hope that LiveData will act as a "barrier" by preventing my context from flowing back to the root of Flowable, but I'm not so sure about that.
In other words:
- Current A exists in a global context
- In each fragment, A is enclosed in LiveData B , which is set as a property of the fragments ViewModel
- When I usually watch LiveData B , I instead port it to Flowable C
- I subscribe to Flowable C and ignore the one-time return
Will viewing access in C leak to A when a fragment is destroyed?