

Having the ability to combine multiple CoroutineContexts, and different context types, to produce powerful coroutine mechanisms makes coroutines really extensible and versatile. However, you did learn what the CoroutineContext is, and what it’s used for.

But you haven’t learned much about how you can deal with threading, and which threading solutions exist within the API itself. Right about now, you’ve amassed a good amount of knowledge about coroutines, suspendable functions and the Kotlin’s Coroutines API. 18.3 Coroutines & Flow in Jetpack Compose.14.1 The Importance of the Android Main Thread.Section III: Coroutines & Android Section 3: 6 chapters Show chapters Hide chapters 8.4 Handling Multiple Child Coroutine Exceptions.1.9 Explaining Coroutines: The Inner Work.1.7 Diving Deeper Into the Complexity of Rx.1.6 Using Reactive Programming for Background Work.1.4 Handling Work Completion Using Callbacks.1.3 Interacting With the UI Thread From the Background.Use this scope when you think that running your coroutine beyond onDestroyView() might access your views and cause exceptions.Section I: Introduction to Coroutines Section 1: 9 chapters Show chapters Hide chapters

It has the same context elements as lifecycleScope. Thus, the coroutine started in v iewLifecycleOwner.lifecycleScope will be cancelled when onDestroyView() is called. Its lifecycle starts when onCreateView() is called and destroys when onDestroyView() is called. In an Activity/Fragment, we have a view’s lifecycle owner - viewLifecycleOwner.
