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!
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?
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?
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.
I am loving your reels like this one. Thanks!
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!
Wow, thanks a lot! Your information take me to the next level.
Love it! Thanks
Thank you ❤
Thank u Philipp ❤
I would like to work with you as an intern :D
Please coulde you add a translation for your videos for arabic please
If however I want to run a computation when the onStop of a fragment is called, what do I use?
Depends on the computation and if it's bound to the screen or not
But what if i added a job inside globalScope context and cancle it anytime isn't work?
Works, but that's independent of what a coroutine scope is used for
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?
Coroutine scope
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?
WorkManager might be your solution
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.
what if globalscope is used inside viewmodel?
It is still a global scope
And viemodelscope?
It lives as long as the viewmodel does
Does Coroutine Scope cancels itself when the code block is finished ?
The job is finished, but a scope needs to be canceled by you
@@PhilippLackner Same question but for GlobalScope, does it get canceled when the code is finished?
Can't we cancel global scope from inside when job is done?
You can cancel the job but not the scope
@@PhilippLackner understood, thank you Philip
What about MainScope() sir?