https://kotlinlang.org logo
#android
Title
# android
k

Ken Maffei

09/02/2020, 4:56 PM
For a fragment, what's the difference, if any, between fragment.lifecycleScope.launch() and fragment.viewLifecycleOwner.lifecycleScope.launch() ?
s

Sebastian Kaspari

09/02/2020, 5:07 PM
The view of a fragment usually has a shorter lifecycle than the fragment. Views can come and go as the fragment gets detached and attached.
If you do something inside your launch block that needs the views, than you probably want to bind this to the viewcycle of the views