Besto
09/29/2021, 4:11 PMonStart() method in my Fragment A. This flow is attached to the viewModelScope .
My question is: when I open another fragment and return to my Fragment A onStart is called again and the register for the flow is called as well, so the flow is called twice without cancel it as it's attached to the viewModelScope and the onCleared method was not called yet .
How do you handle this case to avoid keeping emitting data to the view when the view is not attached ?louiscad
09/29/2021, 11:11 PMokarm
09/30/2021, 7:10 AMBesto
09/30/2021, 12:17 PMviewLifecycleOwner.lifecycleScope should be used in Fragment, however, in my case I need to use a scope in my viewmodellouiscad
09/30/2021, 12:26 PMviewModelScope, but collect the flow in viewLifecycleOwner.lifecycleScope