GlobalScope vs. CoroutineScope - THIS Is the Difference

  Рет қаралды 36,601

Philipp Lackner

Philipp Lackner

Жыл бұрын

Follow for more Android & Kotlin tips 🙌

Пікірлер: 29
@rgfnevess
@rgfnevess 11 ай бұрын
I am loving your reels like this one. Thanks!
@SiamakAshrafi
@SiamakAshrafi Жыл бұрын
OK ... Thanks. And If you ask ChatGPT you get a very good explanation with code examples showing the difference in Compose code which makes it very clear!
@dineshrandy9246
@dineshrandy9246 5 ай бұрын
Wow, thanks a lot! Your information take me to the next level.
@youtubebillwebhome
@youtubebillwebhome 4 ай бұрын
Thank u Philipp ❤
@malandev
@malandev 5 ай бұрын
Thank you ❤
@PostMeridianLyf
@PostMeridianLyf Жыл бұрын
Love it! Thanks
@OmerFarukUcer
@OmerFarukUcer 11 ай бұрын
I would like to work with you as an intern :D
@triton6771
@triton6771 Жыл бұрын
If however I want to run a computation when the onStop of a fragment is called, what do I use?
@PhilippLackner
@PhilippLackner Жыл бұрын
Depends on the computation and if it's bound to the screen or not
@pritishsahoo5467
@pritishsahoo5467 Жыл бұрын
well, I need to download something independent on any activity and it should continue to download even if you switch activities. So in this case what should I use?
@PhilippLackner
@PhilippLackner Жыл бұрын
Coroutine scope
@mhmdawad001
@mhmdawad001 Жыл бұрын
But what if i added a job inside globalScope context and cancle it anytime isn't work?
@PhilippLackner
@PhilippLackner Жыл бұрын
Works, but that's independent of what a coroutine scope is used for
@ahmadprogrammer136
@ahmadprogrammer136 7 ай бұрын
Please coulde you add a translation for your videos for arabic please
@alsh2887
@alsh2887 Жыл бұрын
What if I'm writing something to local DB and want to be sure that the data will be written if the user decides to exit application? Should I use GlobalScope or CoroutineScope with dispather IO?
@thebigboi5357
@thebigboi5357 Жыл бұрын
WorkManager might be your solution
@firstnamelastname-oy7es
@firstnamelastname-oy7es 11 ай бұрын
Could you put a global boolean called "writing data" and then when you launch a data writing co-routine, set it to true, and when your co-routine is done writing data, have it set the boolean to false and cancel it? Then over ride on pause/on destroy so they enter a busy while-loop checking for writing data == false, and when it does equal false, finish up destruction and call super destroy. That way when the user closes the app, the app will hang until data has been finished writing.
@airflow.777
@airflow.777 Жыл бұрын
Can't we cancel global scope from inside when job is done?
@PhilippLackner
@PhilippLackner Жыл бұрын
You can cancel the job but not the scope
@airflow.777
@airflow.777 Жыл бұрын
@@PhilippLackner understood, thank you Philip
@abbasalidaruwala
@abbasalidaruwala Жыл бұрын
what if globalscope is used inside viewmodel?
@mouzinu
@mouzinu Жыл бұрын
It is still a global scope
@Danc243
@Danc243 Жыл бұрын
Does Coroutine Scope cancels itself when the code block is finished ?
@PhilippLackner
@PhilippLackner Жыл бұрын
The job is finished, but a scope needs to be canceled by you
@zakariajawas
@zakariajawas Жыл бұрын
@@PhilippLackner Same question but for GlobalScope, does it get canceled when the code is finished?
@Rektek97
@Rektek97 Жыл бұрын
And viemodelscope?
@mouzinu
@mouzinu Жыл бұрын
It lives as long as the viewmodel does
@mohamedsanoob.k1116
@mohamedsanoob.k1116 Жыл бұрын
What about MainScope() sir?
Let, Also, Apply, Run, With - Kotlin Scope Functions
11:44
Philipp Lackner
Рет қаралды 94 М.
5 Fatal Coroutine Mistakes Nobody Tells You About
18:15
Philipp Lackner
Рет қаралды 85 М.
1❤️
00:17
Nonomen ノノメン
Рет қаралды 13 МЛН
Survival skills: A great idea with duct tape #survival #lifehacks #camping
00:27
Жайдарман | Туған күн 2024 | Алматы
2:22:55
Jaidarman OFFICIAL / JCI
Рет қаралды 1,7 МЛН
Untangling Coroutine Testing by Márton Braun
42:49
Kotlin by JetBrains
Рет қаралды 7 М.
Kotlin Multiplatform vs Flutter: Which should we use?
4:42
Kei Fujikawa
Рет қаралды 15 М.
Be VERY Careful with GlobalScope
13:55
CodingWithMitch
Рет қаралды 13 М.
Coroutine Scopes - Kotlin Coroutines
12:52
Stevdza-San
Рет қаралды 34 М.
How to avoid 5 common Kotlin Coroutine mistakes
15:59
Lukas Lechner - Advanced Android Development
Рет қаралды 4,6 М.
Why Kotlin in 2024🔥  | Java vs Kotlin |
9:06
Easy Tuto
Рет қаралды 3,4 М.
Should You Use Compose State or StateFlow in Your ViewModels?
13:59
Philipp Lackner
Рет қаралды 72 М.
95% Don't Understand THIS About Coroutines (Main-Safety)
9:38
Philipp Lackner
Рет қаралды 26 М.
The Essence of Coroutines
8:10
Dave Leeds
Рет қаралды 6 М.