GlobalScope vs. CoroutineScope - THIS Is the Difference

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is actually the difference between Global scope and the correcting scope in kotlin let's start with global scope Global scope is a carotene scope which lives as long as your whole application does so that also means that all corroutines you launch inside of global scope will inevitably live as long as your application does and there is no way to cancel them all at one go you need to be very careful with global scope though since you can easily get memory leaks if you access resources inside of a global scopical routine which have a shorter life cycle than your whole application like for example the activity context then this can very easily lead to leaks with coroutine scope however we can create an individual correcting scope this is a scope we really control and where we can say is scope.cancel to cancel all core routines in that scope that's very helpful if you create a custom component that has a life cycle where you need core routines in it so unless you really know what you're doing prefer current in scope and cancel the scope as soon as you don't need the curtains anymore do you like these Android and carton tips then follow for more
Info
Channel: Philipp Lackner
Views: 36,667
Rating: undefined out of 5
Keywords: android, androidstudio, coding, compose, hack, intellij, jetpack, keyword, kotlin, lackener, lackner, leckner, philip, philipp, phillip, programming, tips, top
Id: aQw_97TqTQU
Channel Id: undefined
Length: 0min 56sec (56 seconds)
Published: Sat May 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.