Coroutine Scopes - Kotlin Coroutines

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ค. 2024
  • 🏆 My Online Courses
    ⭐Discount Coupon: LAUNCH-STEVDZA-SAN
    stevdza-san.com
    🐱‍👤 Wanna become a member? Join!
    / @stevdzasan
    📸 Instagram
    / stevdza_san
    Kotlin coroutines provide an API that enables you to write asynchronous code. With Kotlin coroutines, you can define a CoroutineScope, which helps you to manage when your coroutines should run. Each asynchronous operation runs within a particular scope.
    Global scope is used to launch top-level coroutines which are operating on the whole application lifetime and are not cancelled prematurely.
    A LifecycleScope is defined for each Lifecycle object. Any coroutine launched in this scope is canceled when the Lifecycle is destroyed.
    A ViewModelScope is defined for each ViewModel in your app. Any coroutine launched in this scope is automatically canceled if the ViewModel is cleared. Coroutines are useful here for when you have work that needs to be done only if the ViewModel is active. For example, if you are computing some data for a layout, you should scope the work to the ViewModel so that if the ViewModel is cleared, the work is canceled automatically to avoid consuming resources.
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
    Other videos:
    The Basics - • The Basics - Kotlin Co...
    Jobs & Cancellation - • Jobs and Cancellation ...
    runBlocking - • runBlocking - Kotlin C...
    withContext - • withContext() - Kotlin...
    🕒Timestamps:
    0:00 - Introduction
    3:00 - Create Coroutine Scope
    7:50 - GlobalScope
    10:47 - lifecycleScope & viewModelScope

ความคิดเห็น • 34

  • @duncanmoiyo6069
    @duncanmoiyo6069 8 หลายเดือนก่อน +2

    You've significantly simplified the comprehension of coroutine scopes. I truly appreciate it.

  • @kristofs8893
    @kristofs8893 2 ปีที่แล้ว +10

    I had no chance of understanding Coroutines, but you made it look so simple!

    • @StevdzaSan
      @StevdzaSan  2 ปีที่แล้ว

      Yay, happy to hear that buddy!

  • @Axelfromthehudjelud
    @Axelfromthehudjelud 2 ปีที่แล้ว +2

    Ok, this is the best explanation of the things that were confusing me. Thank you very much!

  • @TheDamiankain
    @TheDamiankain ปีที่แล้ว

    It amazes me how quickly and easily this topic can be explained and shown !!!

  • @adwatt357
    @adwatt357 2 ปีที่แล้ว

    Loved your explanation style !! Keep up the good work !!

  • @adrienchew
    @adrienchew 3 ปีที่แล้ว +4

    Thank you for all the good content!

  • @ashwin_mahajan
    @ashwin_mahajan 3 ปีที่แล้ว +2

    Very well explained and demonstrated, thank you. 🙌

  • @kwesiamartey
    @kwesiamartey 3 ปีที่แล้ว +1

    That is my man never disappoint, You are the best

  • @100rabhGrwal
    @100rabhGrwal 3 ปีที่แล้ว +7

    Thankyou dear for this easy and understandable explanation 👍

  • @stasleonov5196
    @stasleonov5196 ปีที่แล้ว

    It is amazing! I finally understand what happen when we use lifecyclescope

  • @shadiossaili7377
    @shadiossaili7377 3 ปีที่แล้ว

    Yes please do more videos like this!

  • @TheInvisibleWasTaken
    @TheInvisibleWasTaken 3 ปีที่แล้ว +1

    You are amazing. Thanks for the content.

  • @kmcgill88
    @kmcgill88 2 ปีที่แล้ว +3

    Thanks!

  • @nesibeyyubov554
    @nesibeyyubov554 3 ปีที่แล้ว +1

    best explanation ever, thanks too much

  • @vaibhavarora8793
    @vaibhavarora8793 2 หลายเดือนก่อน

    Thank You , It was very useful.

  • @slobom.6744
    @slobom.6744 ปีที่แล้ว

    Great Explanation, thanks bro

  • @Another0neTime
    @Another0neTime 3 ปีที่แล้ว +1

    The best!

  • @michaelappiah-kubi2829
    @michaelappiah-kubi2829 8 หลายเดือนก่อน

    Thank you

  • @Mkumarei
    @Mkumarei 3 ปีที่แล้ว

    Thank you ...

  • @nicolasvantsis6166
    @nicolasvantsis6166 3 ปีที่แล้ว

    Very nice

  • @turtle733
    @turtle733 2 ปีที่แล้ว

    +1 thank you :)

  • @pavelgera72
    @pavelgera72 ปีที่แล้ว

    хорошие видео для понимания

  • @sumit180288
    @sumit180288 3 ปีที่แล้ว +1

    Make a detailed video on Coroutine Jobs

  • @anudeepananth
    @anudeepananth 3 ปีที่แล้ว

    So there is no way to use a LifecycleScope or ViewModelScope inside of an Adapter class?

  • @giorgikakhetelidze2115
    @giorgikakhetelidze2115 2 ปีที่แล้ว

    What is difference between CoroutineScope and GLobalScope about their lifcecycles? when CoroutineScope Cancells autmatically?

  • @pinoy_marites_beh
    @pinoy_marites_beh ปีที่แล้ว

    what if you created an infinite loop without using "delay" and instead system time difference, I think it will not be cancelled even if the coroutine is tied to the lifecycle.

  • @ajayvamsee7508
    @ajayvamsee7508 6 หลายเดือนก่อน

    So you mention global scope coroutine will run even fragment A is destroyed but after again come back to fragment A the fragment A will start again right then coroutine will start again..
    So we have 2 coroutines or what will happens..?

  • @baur22
    @baur22 3 ปีที่แล้ว

    Will there be a jetpack compose course?

    • @StevdzaSan
      @StevdzaSan  3 ปีที่แล้ว +2

      Definitely in the future

  • @roushanali1918
    @roushanali1918 2 ปีที่แล้ว

    I like this... but want to know is there any better content for proffessionals?

  • @nileshdhawale2138
    @nileshdhawale2138 3 ปีที่แล้ว

    When u create video use android studio default theme, it will be very clear for visibility as compare to dracula theme