Understand Kotlin Coroutines on Android (Google I/O'19)
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;
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. 🤯
The goal is basically set at
Thanks guys. Very helpful. Have you shared the lecture notes?
Hi Team,
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.
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.
23:46
I agree, iti s interesting and useful. Thank you.
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.
Few years from now they will come up with new way for async programming and say coroutines sucks.
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?
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
Its interesting and usefully..Thanks
Best explanation of coroutines i've seen!
Are there any complete samples on github?
It would be great if they put the slides in somewhere
About
At around
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...
how to communication corotines to UI in jetpack composables? because we can update UI only in composables