When using the MVVM-Pattern. Which scope should be used in a repository when doing network request or reading/writing a database? If we have a viewmodel that calls the repository should we pass the underlying lifecycle and then use this lifecycle as a scope for the coroutine?
It's not the job of the repository to start the coroutine. Just use suspend functions in the repo and in the viewmodel you execute them with viewmodelscope
so lifecyclescope is meant to stick that coroutine to activity lifecyle , if app is ondestroy mode , the coroutine will be dismised as wel to not cause memory leak and for the viewmodelscope is meant to be used with viewmodel as it sticks to viewmodel lifecyle so when viewmodel is cleared , the coroutine is cleared too , but little question , what is the point of having this global scope , like what is the advantage of having it , thank you so much , and as always great video , good work
Thanks 👍 sometimes you want a coroutine to be alive as long as the app. Imagine doing a calculation that affects your entire app, you don't want to cancel that calculation when you switch the activity
alright yeah so you mean if there is a work that needs to be processed continuously while app is on foreground , in this case global scope is the best choice right
@@AlgeriaHere yes, you also have to think that kotlin is n ot only for android and PC programs dont usually have a lifecycle, so there GlobalScope is probably used more frequently
Is it right, that the coroutine holds automatically a reference of the activity from which they were started even if it doesn't use any resources of the activity? So the activity or resources won't be garbage collected even the coroutine use no ressources of the activity?
My question is when a Global scope routine finishes it job, does it automatically get deleted from the memory or does it still remain there? Another question is that when the lifecycle scope is finished with the job, does it get deleted as well while the fragment or activity is still operating? Thanks for your response in advance. (Danke schon)
It was an old deprecated method of accessing views without findViewById ,kotlin Synthetics, its deprecated now but I guess it still worked at the time this video was created
Hi Philipp, in Which thread does the lifecycle scope starts coroutines by default? Can we also use Dispatchers to start the coroutine in specific thread while using lifecycle scope?
Sir, what about the coroutine that starts another activity, will it continue to exist even if the task is complete or will it get destroyed with the finish call or with the completion of the code block? Sry if my doubt is too obvious. Please reply and how do you don't need to use findViewById()?
search for quality content on coroutines ends here , keep up the good work brother
"Increase text size a little bit..to 50sp"
I had a good laugh from that. )))
Ты очень хорошо объясняешь
Please cover custom coroutine scopes and the differences between that and the built-in ones. Thanks.
Your videos are very sound. They do what they got to do. Great job!
Thank you clear explanation ❤
Thank you very much for such useful material!
Amazing series
Quality content....keep uploading more videos...hope your channel will be popular soon...
Thank you so much 😀
these are very easy to understand videos. I am so appriciate that, so I did press the like button twice..
When using the MVVM-Pattern. Which scope should be used in a repository when doing network request or reading/writing a database? If we have a viewmodel that calls the repository should we pass the underlying lifecycle and then use this lifecycle as a scope for the coroutine?
It's not the job of the repository to start the coroutine. Just use suspend functions in the repo and in the viewmodel you execute them with viewmodelscope
@@PhilippLackner Thank you!
Thank you so much for this awesome series.
Thank you ❤️
Good explanation thanks
Amazing series of videos, thank you.
Very clear explanation! keep it up
great video
brilliant
Very helpful ❤
great!
Спасибо
really nice example, keep it up
Thanks i got it solved
nice
Nice work can you please make detail videos regarding scope is created and cancellations and exceptional handling in coroutine.
amazing bro !!!learning a lot
Danke
Bitte :D
Very helpful
Could you also spot out difference between suspend fuction and completedeferred ? 6:24
Please add more teoretics parts to video
vídeo muito bom, BR não desista só pq o vídeo está em inglês.
Hi bro, did you have "How to run a coroutine in Service" videos.
Hey, How can you set up onClickListerner without findviewbyId and Viewbinding. I cannot do that in my android studio
so lifecyclescope is meant to stick that coroutine to activity lifecyle , if app is ondestroy mode , the coroutine will be dismised as wel to not cause memory leak and for the viewmodelscope is meant to be used with viewmodel as it sticks to viewmodel lifecyle so when viewmodel is cleared , the coroutine is cleared too , but little question , what is the point of having this global scope , like what is the advantage of having it , thank you so much , and as always great video , good work
Thanks 👍 sometimes you want a coroutine to be alive as long as the app. Imagine doing a calculation that affects your entire app, you don't want to cancel that calculation when you switch the activity
alright yeah so you mean if there is a work that needs to be processed continuously while app is on foreground , in this case global scope is the best choice right
@@AlgeriaHere yes, you also have to think that kotlin is n ot only for android and PC programs dont usually have a lifecycle, so there GlobalScope is probably used more frequently
@Raunak Nandan Singh Interesting, thanks !
Is it right, that the coroutine holds automatically a reference of the activity from which they were started even if it doesn't use any resources of the activity? So the activity or resources won't be garbage collected even the coroutine use no ressources of the activity?
Nice vid dude
Thanks!
Can you also create videos about channels and flows in Kotlin
My question is when a Global scope routine finishes it job, does it automatically get deleted from the memory or does it still remain there? Another question is that when the lifecycle scope is finished with the job, does it get deleted as well while the fragment or activity is still operating? Thanks for your response in advance. (Danke schon)
how are you use btnStartActivity without using any view binding?
I couldn't get it too. How...?
:) Thanks
Welcome!
may i ask, why you can do click a button (setonclicklistener) inside mainActivity without findViewById?
and if you use viewBinding, we do with binding.btn.setOnClick right? then how can you just type btn.setOnClick?
It was an old deprecated method of accessing views without findViewById ,kotlin Synthetics, its deprecated now but I guess it still worked at the time this video was created
How does CoroutineScope fit into this subject?
When calling API by onSwipeRefreshlistener under viewModelScope.launch getting error Job was canceled please help. Thanks
Hi Philipp, in Which thread does the lifecycle scope starts coroutines by default? Can we also use Dispatchers to start the coroutine in specific thread while using lifecycle scope?
by default it's the main dispatcher. You can change that as with any other scope as well
@@PhilippLackner but why a scope will start a coroutine in the Main thread? The purpose of Coroutine is to free the main thread right?
Very neat and clean explanation. Thanks for this video. Do you have twitter account ? I want to share over there
Thanks man! No currently I don't, I wouldn't know what to post there 😂
@@PhilippLackner Ok when you will have let me know
@@ManishPatel3030 He has one now
Thanks for the informations . In the vedio of viewpager 2 how can we make the images show in all screen
In all screen?
I mean full screnn size
@@mlktech1531 May be you should set layout height and width of ImageView to "match-parent"
Sir, what about the coroutine that starts another activity, will it continue to exist even if the task is complete or will it get destroyed with the finish call or with the completion of the code block? Sry if my doubt is too obvious. Please reply and how do you don't need to use findViewById()?
in kotlin we don't need findViewById()
Detailed explanation would have been better about scope
I don't get understand enough :(