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

preview_player
Показать описание
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 #io19 here:

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. 🤯

DeLL
Автор

"suspend fun" sounds so sad... :(

XeaLStorm
Автор

Kotlin documentation for coroutines sucks (to say the least)!

famketheron
Автор

The goal is basically set at 4:26 but at the end of the video it feels like(as always) we are back to square one.
On the hindsight making anything comprehensive and simple with fragment + activity with their lifecycles is incredibly complex. Throw in a service(Which connects asynchronously and has its own foreground limitations) that needs to be connected and you have to throw everything out of the window.

AnkitGusai
Автор

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

saurabhprakash
Автор

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

megaTiagoNunes
Автор

Sorry but who are these developers you guys are supposedly talking to? How many completely different async solutions are there now for Android? Like 30? Do all these developers constantly want to learn new ways to perform async tasks?

Maarttttt
Автор

Ouch, all this is so awfully complicated, I guess I will stick with good old callbacks.

alxkub
Автор

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.

hitec
Автор

I don't get how Coroutines are presented as an "easy" solution.. They are very hard instead to use properly. I'm trying get it but it's far from easy.. Am I the only one?

DiegoTube
Автор

Best explanation of coroutines i've seen!

matthieulucas
Автор

About 30:00, I don't understand how this works.
It runs this peace of code on the UI thread, on start, right?
So how come it waits for "note" variable to be fetched?
Does it also re-load the data this way, each time it gets changed, or does it load it just once?

LiranBarsisa
Автор

23:46 yeah but cancelation is cooperative, the while loop has to check for isActive property of the coroutine and break from the loop.

udhdbdjxisskka
Автор

I don't event know what is better: write some boilerplate code but know what is going on, or learn a lot of new abstractions which you do not fully understand

zim
Автор

do you seriously think that coroutines are easier than mvp with rx? I was expecting something really easy but got frustrated.

krokenstiv
Автор

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

ftabashir
Автор

At around 28:56 should this do the job also:
suspend fun loadNote(): Note = viewModelScope.async { repository.loadNote() }
I don't see the point on this CompletableDeferred. If it should be loaded only once you could use the lazy delegate.
Why is CompletableDeffered needed?

ericmartorilopez
Автор

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.

EdouardTavinor
Автор

android development would soon require to be only attempted by stuntmen and Phds. Phds who possibly had two or three Masters in various fields of maths science and computations

codingCouncil
Автор

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.

fredrik.larsen