lifecycleScope and viewModelScope - Kotlin Coroutines

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии •

  • @ravish2038
    @ravish2038 3 года назад +1

    search for quality content on coroutines ends here , keep up the good work brother

  • @xKuroiKazex
    @xKuroiKazex 2 года назад +2

    "Increase text size a little bit..to 50sp"
    I had a good laugh from that. )))

  • @pavelgera72
    @pavelgera72 Год назад +1

    Ты очень хорошо объясняешь

  • @professorposh4146
    @professorposh4146 2 года назад +3

    Please cover custom coroutine scopes and the differences between that and the built-in ones. Thanks.

  • @chimezieorji-unegbu7110
    @chimezieorji-unegbu7110 3 года назад

    Your videos are very sound. They do what they got to do. Great job!

  • @Progamingff1
    @Progamingff1 11 месяцев назад

    Thank you clear explanation ❤

  • @ЄвгенійКобахидзе
    @ЄвгенійКобахидзе 3 года назад +1

    Thank you very much for such useful material!

  • @naruebetphramrit4706
    @naruebetphramrit4706 3 года назад

    Amazing series

  • @jakariamasudliton
    @jakariamasudliton 4 года назад +2

    Quality content....keep uploading more videos...hope your channel will be popular soon...

  • @thonguyen252
    @thonguyen252 3 года назад

    these are very easy to understand videos. I am so appriciate that, so I did press the like button twice..

  • @kryzz1592
    @kryzz1592 4 года назад +7

    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?

    • @PhilippLackner
      @PhilippLackner  4 года назад +24

      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

    • @kryzz1592
      @kryzz1592 4 года назад +2

      @@PhilippLackner Thank you!

  • @Kunal-jp8tn
    @Kunal-jp8tn 3 года назад

    Thank you so much for this awesome series.

  • @rishabhgupta655
    @rishabhgupta655 2 года назад

    Thank you ❤️

  • @haseen5
    @haseen5 3 года назад

    Good explanation thanks

  • @daniboy943
    @daniboy943 2 года назад

    Amazing series of videos, thank you.

  • @ReyAlexam
    @ReyAlexam 3 года назад

    Very clear explanation! keep it up

  • @rahulh6711
    @rahulh6711 2 года назад

    great video

  • @user-my6yf1st8z
    @user-my6yf1st8z 2 месяца назад

    brilliant

  • @bassamnasser7953
    @bassamnasser7953 Год назад

    Very helpful ❤

  • @denis_artemov
    @denis_artemov 4 месяца назад

    great!

  • @pavelb3734
    @pavelb3734 4 года назад +2

    Спасибо

  • @droidcasts7350
    @droidcasts7350 3 года назад

    really nice example, keep it up

  • @abhishekauti164
    @abhishekauti164 3 года назад

    Thanks i got it solved

  • @hades5444
    @hades5444 3 года назад

    nice

  • @ganeshjogam7837
    @ganeshjogam7837 4 года назад

    Nice work can you please make detail videos regarding scope is created and cancellations and exceptional handling in coroutine.

  • @brucebane7401
    @brucebane7401 3 года назад

    amazing bro !!!learning a lot

  • @mohameddarwish1347
    @mohameddarwish1347 4 года назад +1

    Danke

  • @ChrisAthanas
    @ChrisAthanas 4 года назад

    Very helpful

  • @larrystreehouse1124
    @larrystreehouse1124 Год назад +1

    Could you also spot out difference between suspend fuction and completedeferred ? 6:24

  • @TheMrAntosiek
    @TheMrAntosiek 2 года назад +1

    Please add more teoretics parts to video

  • @Marcoscsouzads
    @Marcoscsouzads 2 года назад

    vídeo muito bom, BR não desista só pq o vídeo está em inglês.

  • @Joe-yu9wc
    @Joe-yu9wc 3 года назад

    Hi bro, did you have "How to run a coroutine in Service" videos.

  • @sanskarsharma100
    @sanskarsharma100 3 года назад

    Hey, How can you set up onClickListerner without findviewbyId and Viewbinding. I cannot do that in my android studio

  • @AlgeriaHere
    @AlgeriaHere 4 года назад +1

    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

    • @PhilippLackner
      @PhilippLackner  4 года назад +2

      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

    • @AlgeriaHere
      @AlgeriaHere 4 года назад +1

      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

    • @PhilippLackner
      @PhilippLackner  4 года назад +1

      @@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

    • @yannism9594
      @yannism9594 3 года назад +1

      @Raunak Nandan Singh Interesting, thanks !

  • @wolfrudel7624
    @wolfrudel7624 2 года назад

    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?

  • @dawoodamir2011
    @dawoodamir2011 4 года назад

    Nice vid dude

  • @ganeshjogam7837
    @ganeshjogam7837 4 года назад

    Can you also create videos about channels and flows in Kotlin

  • @fatihsevbanuyank594
    @fatihsevbanuyank594 2 года назад

    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)

  • @mujahidansorimajid1524
    @mujahidansorimajid1524 2 года назад +1

    how are you use btnStartActivity without using any view binding?

    • @kheifs
      @kheifs Месяц назад

      I couldn't get it too. How...?

  • @ajaygalagali5963
    @ajaygalagali5963 4 года назад

    :) Thanks

  • @wahyukoco4562
    @wahyukoco4562 2 года назад

    may i ask, why you can do click a button (setonclicklistener) inside mainActivity without findViewById?

    • @wahyukoco4562
      @wahyukoco4562 2 года назад

      and if you use viewBinding, we do with binding.btn.setOnClick right? then how can you just type btn.setOnClick?

    • @FelixEsUnDios
      @FelixEsUnDios 2 года назад

      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

  • @ericgoto2459
    @ericgoto2459 4 года назад

    How does CoroutineScope fit into this subject?

  • @islamicthoughts5030
    @islamicthoughts5030 3 года назад

    When calling API by onSwipeRefreshlistener under viewModelScope.launch getting error Job was canceled please help. Thanks

  • @raghavaggarwal8644
    @raghavaggarwal8644 3 года назад

    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?

    • @PhilippLackner
      @PhilippLackner  3 года назад +1

      by default it's the main dispatcher. You can change that as with any other scope as well

    • @raghavaggarwal8644
      @raghavaggarwal8644 3 года назад

      @@PhilippLackner but why a scope will start a coroutine in the Main thread? The purpose of Coroutine is to free the main thread right?

  • @ManishPatel3030
    @ManishPatel3030 4 года назад +1

    Very neat and clean explanation. Thanks for this video. Do you have twitter account ? I want to share over there

    • @PhilippLackner
      @PhilippLackner  4 года назад +3

      Thanks man! No currently I don't, I wouldn't know what to post there 😂

    • @ManishPatel3030
      @ManishPatel3030 4 года назад +1

      @@PhilippLackner Ok when you will have let me know

    • @codinginflow
      @codinginflow 4 года назад +3

      @@ManishPatel3030 He has one now

  • @mlktech1531
    @mlktech1531 4 года назад

    Thanks for the informations . In the vedio of viewpager 2 how can we make the images show in all screen

    • @PhilippLackner
      @PhilippLackner  4 года назад

      In all screen?

    • @mlktech1531
      @mlktech1531 4 года назад

      I mean full screnn size

    • @ajaygalagali5963
      @ajaygalagali5963 4 года назад

      @@mlktech1531 May be you should set layout height and width of ImageView to "match-parent"

  • @rp2332
    @rp2332 2 года назад

    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()?

  • @ganeshjogam7837
    @ganeshjogam7837 4 года назад

    Detailed explanation would have been better about scope

  • @tejasgalande4557
    @tejasgalande4557 2 года назад

    I don't get understand enough :(