I have couple of (nested) fragments, for which I'd like to persist arbitrary data. I don't want to use regular singletons, because then the memory would never be freed, even after leaving particular part of the app.
I've been researching Dagger and Mortar, but I can't think of a way to have child object graph that is tied to a fragment, but which is also retained across configuration changes - most examples just show object graph per activity, but that doesn't help at all (since it'd be destroyed farily quickly).
The only thing I could think of are either storing the graph in a retained fragment, which doesn't actually help, or in Application
class. But then how can I know when should I free the graph?
Overall my problem is how to use Dagger's child object graph in Android ecosystem, where everything except from Application
is destroyed every once in a while