Closed alan-rodriguez closed 4 years ago
Thank you for bringing this up. I agree that the renderer
method should be bound to the view lifecycle instead of the fragment lifecycle. However, changing fragmentScope
would be a potentially breaking change.
As alternative, i can introduce a viewScope
Coroutine scope to VectorFragment
and bind the renderer method to it. Would this be an acceptable solution to you?
Under the hood viewScope
can simply act as an alias for viewLifecycleOwner.lifecycleScope
.
Describe the bug The fragment's view is destroyed before
fragmentScope
is cancelled inonDestroy()
, which can cause crashes if the renderer directly references any views. The usage of data binding in the sample fragments prevents this from happening, but consumers of the library may not be using data binding.Expected behavior Use
viewLifecycleOwner.lifecycleScope
from lifecycle-runtime-ktx or manually managefragmentScope
according to the Fragment's View lifecycle.