I have an activity containing bottom navigation and 3 fragments. I use the repository pattern, lets say its all about user object. Currently, each fragment has its own presenter that i’m instantiating in the onCreateView. I attach the view in onCreateView and detach it in onDestroyView. If I navigate to another fragment ,rotate the screen or the process dies, the presenters will be just recreated for each scenario and I will get the user object from the repository again (it is cached and therefore no heavy operations each time). Now for the problematic scenario:
User clicks to upload a photo -> the photo is being uploaded and the view presents a loading indicator->user navigates out of the fragment->view is detached-> the presenter unsubscribes for the upload complete listener of the repository ->user navigates back to the first fragment -> a new presenter is created and attached -> he neither sees any photo nor an uploading indicator (the uploading is still in progress but there are no subscribers anymore)
Now there are few options:
- I am missing something
- I am missing something very basic
- I should keep an active listener to catch any change(currently using single listener)
- I should assume success when uploading an image but then I will not know about the failure
What am I missing?