I am using nested fragments so fragment1 opens fragment2 and they share a viewmodel. This viewmodel calls a repository to get data and using a LiveData it posts the result and then fragment2 displays the data.
My problem was the second time fragment1 opened fragment2, for a brief moment fragment2 was displaying the previous data. I could solve this problem using a similar approach to this post Android Arch Components ViewModel and LiveData trigger after screen rotation using SingleLiveEvent.
However, now my issue is that on screen rotation, data is not delivered again (since it is done a single time) and fragment2 screen remains blank.
I was thinking on modifying SingleLiveEvent so it sometimes delivers data a single time but other times to make it deliver again using a condition or something similar.
Does anybody knows what approach could I use here?