KotlinConf 2019: Coroutines! Gotta catch 'em all! by Florina Muntenescu & Manuel Vivo

  Рет қаралды 50,355

JetBrains

JetBrains

4 жыл бұрын

Recording brought to you by American Express. americanexpress.io/kotlin-jobs
You've added #coroutines to your app and everything is fine while your users are on the happy path. But what happens if you cancel a coroutine, you get a timeout or other type of error? Where do you handle it?
Kotlin added structured concurrency to scope the lifetime of a coroutine. But what kind of scopes should you use? How do scopes affect error handling? Does the way you start a coroutine, using launch or async have any effect on the type of errors or the way you handle them?
In this talk we'll go over all of these use cases and show how they can be implemented to ensure robust error handling and a good user experience, even when you're thrown off the happy path.
Resources:
KotlinConf website: jb.gg/fyaze5
KotlinConf on Twitter: / kotlinconf
Kotlin website: jb.gg/pxrsn6
Kotlin blog: jb.gg/7uc7ow
Kotlin on Twitter: / kotlin
#KotlinConf19 #Kotlin #JetBrains
About the Presenters:
Florina is working as an Android Developer Advocate at Google, helping developers architect clean, testable apps using the Architecture Components libraries. She has been working with Android for 8 years, previous work covering news at upday, payment solutions at payleven and navigation services at Garmin.
Manuel is an Android Developer in the Developer Relations team at Google where he works to help other developers succeed.

Пікірлер: 48
@codinginflow
@codinginflow 3 жыл бұрын
Jesus Christ that's confusing
@j2shoes288
@j2shoes288 3 жыл бұрын
"RxJava was confusing, so, we now have Coroutines that makes is easier and simple to use" 2 yrs later "Coroutines was confusing, so, we now have XXX that makes is easier and simple to use"
@mohsenteymouri5426
@mohsenteymouri5426 3 жыл бұрын
Because they have deep dive in under the hood bro, don't worry about that.
@marcelohernandez229
@marcelohernandez229 4 жыл бұрын
Great talk! I love Coroutines, but trying to grasp exception handling is quite the learning curve. One thing to be mindful of is that when using runCatching or try/catch (Throwable), this will also catch the CancellationException when Coroutines are cancelled. However, this Exception is a special case and should not be treated as any other exception. It should be re-thrown in order to allow the Coroutine cancellation mechanics to work as intended.
@LogicPhalanx
@LogicPhalanx 3 жыл бұрын
Very useful information. Thank you.
@j2shoes288
@j2shoes288 3 жыл бұрын
that was so confusing that we'll have to write our own code, to test whether or not what he said was true! ridiculous
@puneetgoyal4561
@puneetgoyal4561 2 жыл бұрын
great talk :)
@karahsekir5494
@karahsekir5494 2 жыл бұрын
Great presentation, thank you. The coroutine API is just terrible. The propagation rules are unclear (when can who inherit what) the most telling is the Job/SupervisorJob example around 25:00 where I also thought the their parent is SupervisorJob (when in fact it was Job). Kotlin fixed a lot of Java issues but when it came to creating their own API they messed up just as Java. Nonetheless it’s still the best language on the JVM.
@rollebonmarquis7574
@rollebonmarquis7574 Жыл бұрын
I got confused at this part as well. Though, I think that the presentation at 05:20 and onwards can help & does explain why does this at 25:00 happens (in my current understanding).
@dmytropashko2437
@dmytropashko2437 4 жыл бұрын
I got a new challenge to calculate how many times she said cancel, cancelled or cancelable 😂😂😂
@sauravsingh7216
@sauravsingh7216 3 жыл бұрын
I've seen Manuel using the sentence "what's going under the hood" at least one time in every video..
@chiragprajapati3989
@chiragprajapati3989 2 жыл бұрын
Can we please get the presentation shown in video?
@randomrainforest
@randomrainforest 3 жыл бұрын
coroutines in quarantine ;P
@robchr
@robchr 3 жыл бұрын
Way simpler than RxJava (ಠ_ಠ)
@islamassem2448
@islamassem2448 3 жыл бұрын
I hope if you can provide English translation as auto translation is massed up
@zekininadresi
@zekininadresi 2 жыл бұрын
at 26:45 -> if child fails with an "uncaught" exception, then how the supervisorScope is supposed to not fail? it was just said it would 2-3 slides prior to that point. maybe i did misunderstand what is meant by "if the child job fails"?
@laujimmy9282
@laujimmy9282 3 жыл бұрын
How come if I changed while (i < 5) to for ( i in 0 .. 4) the coroutine cancelled successfully right after printing "Hello 0" ?
@laujimmy9282
@laujimmy9282 3 жыл бұрын
So for people who have the same question. It's because the effect of the while loop and the for loop are different. since " i " does not increment every time while loop goes around, it would run more than 5 times. in order to have the same or similar effect as while loop. We can change it to for (i in 0 .. Int.MaxValue)
@oldergod
@oldergod 3 жыл бұрын
Good presentation, thank you
@JetBrainsTV
@JetBrainsTV 3 жыл бұрын
Glad you enjoyed it!
@ekkolin7527
@ekkolin7527 2 жыл бұрын
Where is the download address of PPT?
@minthetnaing862
@minthetnaing862 5 ай бұрын
Exception 20:50
@eldathray9703
@eldathray9703 4 жыл бұрын
Great talk! But I have to say it's a little too fast for me...maybe because I'm not English-native, but other talk don't give me such feeling.
@Dmitry_Timchenko
@Dmitry_Timchenko 3 жыл бұрын
Yes, Manuel's spoken English is not very good, contrary to Florina, who speaks excellently.
@tejaa2532
@tejaa2532 3 жыл бұрын
The kotlin developer advocate team from Jetbrains and Android dev rel team needs to conduct English pronunciation classes for non native speakers :P.
@yuez.4505
@yuez.4505 3 жыл бұрын
it is very useful, can you translate it in chinese?
@mihaimanole2643
@mihaimanole2643 4 жыл бұрын
Be careful what's your job: to supervise or not 😝🤔 Why should be complicated? I think I heard somewhere about supervisors... In Erlang I think. Yeah, it's Erlang's legacy. I hope to have a good reason.
@hectorantoniotafoyagarcia4735
@hectorantoniotafoyagarcia4735 2 жыл бұрын
Well it's not thaaat confusing, however the part at 25:30 and 35:00 are very poor design decisions.
@ThePujjwal
@ThePujjwal 3 жыл бұрын
It seems developers of the Kotlin coroutines think that people don't have much complexity to deal with in life and as if developers have all the time in the world to understand coroutines. Couldn't this had been simpler ???
@papanino4415
@papanino4415 4 жыл бұрын
This is why I can't wrap my head around coroutines. You hear something from one source but you find out the opposite from another. First Florina says that cancelling child coroutines does not cancel the parent's scope, 15 mins later Manuel says that cancelling a child coroutine cancels its parent and all its siblings. WHICH IS IT?!
@osamamagdy8285
@osamamagdy8285 4 жыл бұрын
cancel != failed
@rajataggarwal743
@rajataggarwal743 2 ай бұрын
case 1: If you cancel a child coroutine willingly (job?.cancel), its not gonna affect its parent. case 2: If child coroutine gets cancelled due to some exception which is not handled, it will propagate up to the parent..doing chaos. This is what I think the scenario is. Corrections welcomed if any :)
@francescafavilli6446
@francescafavilli6446 2 жыл бұрын
I'm half way through and can't help to ask myself... seriously?!? And all of this abstraction is supposed to be easier than raw multithreading in C?
@Dmitry_Timchenko
@Dmitry_Timchenko 3 жыл бұрын
Seems too complicated. In Go, _goroutines_ are much simpler.
@user-xo3cw3bd5o
@user-xo3cw3bd5o 4 жыл бұрын
KOT... BLIN, JAVA... BLIN
@user-xo3cw3bd5o
@user-xo3cw3bd5o 4 жыл бұрын
KOTLIN abr karma object trans-language idiotos nature
@YaLi-jb4vw
@YaLi-jb4vw 4 жыл бұрын
这个女的不是Google的员工吗? 共享员工?
@mohsenteymouri5426
@mohsenteymouri5426 3 жыл бұрын
yes bro
@ThePujjwal
@ThePujjwal 3 жыл бұрын
It's already an arcane topic and the way this young man is speaking English, that's making it further difficult to understand.
The day of the sea 🌊 🤣❤️ #demariki
00:22
Demariki
Рет қаралды 105 МЛН
아이스크림으로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 16 МЛН
Tag her 🤭💞 #miniphone #smartphone #iphone #samsung #fyp
0:11
Pockify™
Рет қаралды 20 МЛН
ИГРОВОВЫЙ НОУТ ASUS ЗА 57 тысяч
25:33
Ремонтяш
Рет қаралды 339 М.