Understand Kotlin Coroutines on Android (Google I/O'19)

Share
Embed
  • Published on May 7, 2019
  • Coroutines are a feature of Kotlin that help convert callback-based code into sequential code, making code easier to read, write, and understand. This session will show you how to use coroutines on Android, and how the new androidx-concurrent library makes it easy to use them to get things off the main thread. You'll also learn how the new library helps coroutines work with Architecture Components. This session also covers coroutine patterns, best practices, and even how to test coroutines!
    Watch more here:
    Android & Play at Google I/O 2019 Playlist → goo.gle/2GRWlQh
    Google I/O 2019 All Sessions Playlist → goo.gle/io19allsessions
    Learn more on the I/O Website → google.com/io
    Subscribe to the Android Developers Channel → goo.gle/AndroidDevs
    Get started at → developer.android.com/
    Speaker(s): Yigit Boyar, Sean McQuillan, Sergey Vasilinetc
    TF7514 event: Google I/O 2019; re_ty: Publish; product: Android - Languages; fullname: Sean McQuillan, Yigit Boyar;

Comments • 119

  • DeLL116
    DeLL116 3 years ago +187

    It's crazy how much has changed in Android development in less than 4 years. It's like I learn something, and by the time I've mastered it something new is made to replace what I've just mastered. 🤯

  • Ankit Gusai
    Ankit Gusai 2 years ago

    The goal is basically set at

  • Farzad Tabashir
    Farzad Tabashir 3 years ago +1

    Thanks guys. Very helpful. Have you shared the lecture notes?

  • soundiscomforting
    soundiscomforting 3 years ago

    With more focus on Rx in general, Google should show why a reactive paradigm is the way to go. RxJava is a solution for this, coroutines with Flow will also provide a way to achieve it. But this is my issue with comparing RxJava and Coroutines currently. They are not comparable.

  • hitec16
    hitec16 2 years ago +8

    so many methods and so many scopes. It feels like patch work rather than a complete solution to handling thread calls and orientation changes. Specially in case of fragment. I am sure in future a lot more stuff will come to fix what is done right now. IMHO fragments itself should be re-written. For a beginner this is a very steep learning curve.

  • chubbaka17

    23:46

  • Davide Spano

    I agree, iti s interesting and useful. Thank you.

  • Edouard Tavinor

    i think the solution with an explicit context as used by go is easier to reason about than this hidden-in-the-background idea of cancellation.

  • Saurabh Prakash
    Saurabh Prakash Year ago +45

    Few years from now they will come up with new way for async programming and say coroutines sucks.

  • ellasaro

    Isn't the statement "Kotlin calls loadUser just like a normal function" sort of inaccurate? Wouldn't you need to use either launch or async, for instance? So when the loadUser suspend function is called, the first thing that gets "suspended", in the flow of things, would be that wrapping coroutine, right?

  • Juker
    Juker 3 years ago +6

    Wow! This session was just... perfect! Crazy how much easier and clearer this is compared to the workarounds devs had to do before, really shows how much we can improve tech even now. Really well explained and complete. Would be great if videos like these showing how to use a new feature from the ground up and relating it to other modern libraries were more common. Good work <3

  • Sasi Kumar
    Sasi Kumar 2 years ago

    Its interesting and usefully..Thanks

  • Matthieu Lucas
    Matthieu Lucas 2 years ago

    Best explanation of coroutines i've seen!

  • Andrey Kadatsky
    Andrey Kadatsky 3 years ago +5

    Are there any complete samples on github?

  • Sina Rahimi
    Sina Rahimi 2 years ago +1

    It would be great if they put the slides in somewhere

  • Liran Barsisa
    Liran Barsisa 2 years ago

    About

  • Eric Martori Lopez
    Eric Martori Lopez 3 years ago +2

    At around

  • M Dapp
    M Dapp 2 years ago +2

    Looking at the actual code of the LifecycleCoroutineScope, I don't think it works the way they claim. Specifically, I don't see any code that would cause coroutines started with 'launchWhenStarted' to suspend when the state is < STARTED. The only thing LifecycleCoroutineScope seems to actually do is cancel when the lifecycle owner is DESTROYED. I'm wondering how much of this talk is actually useable...

  • yasoda nagulla
    yasoda nagulla Year ago

    how to communication corotines to UI in jetpack composables? because we can update UI only in composables