Це відео не доступне.
Перепрошуємо.
Async and Await - Kotlin Coroutines
- Додати в
- Мій плейлист
- Переглянути пізніше
- Поділитися
Поділитися
Вставка
Розмір відео:
- Опубліковано 19 сер 2024
КОМЕНТАРІ • 121
Наступне
Автоматичне відтворення
lifecycleScope and viewModelScope - Kotlin CoroutinesPhilipp Lackner
Переглядів 51 тис.
5 Fatal Coroutine Mistakes Nobody Tells You AboutPhilipp Lackner
Переглядів 86 тис.
.NET Conf: Focus on AIdotnet
Переглядів 1,2 тис.
7 Days Stranded In A CaveMrBeast
Переглядів 68 млн
МАФИЯ в РЕАЛЬНОЙ ЖИЗНИ: Масленников, Матвиенко, Булкин, Сабина, Бустер, Дилара, Гурам, Леон, ЯнчикДима Масленников
Переглядів 8 млн
КАПИТАНА С КУРСКОЙ ОБЛАСТИ, НЕ ПРИЗНАЮТ РОДИТЕЛИ. РОМА ИЛИ НЕ РОМА? @dmytrokarpenkoApostle Dmytro Karpenko
Переглядів 1,2 млн
Вони ЛЕДЬ ХОДЯТЬ! КЕП в ефірі сказав ТЕ, про ЩО ВСІ МОВЧАТЬТСН
Переглядів 900 тис.
Real Interview with Big Bank Corp - Senior Android Developer position - 14 QuestionsOday
Переглядів 43 тис.
Kotlin Coroutines 101 - Android Conference TalksAndroid Developers
Переглядів 134 тис.
How This New Battery is Changing the GameUndecided with Matt Ferrell
Переглядів 33 тис.
MVVM vs. MVI - Understand the Difference Once and for AllPhilipp Lackner
Переглядів 38 тис.
What is the Context? - Android Basics 2023Philipp Lackner
Переглядів 54 тис.
Make Your Code Clean With the SOLID PrinciplesPhilipp Lackner
Переглядів 97 тис.
Kotlin Flows in a NutshellPhilipp Lackner
Переглядів 58 тис.
Бутылка Air Up обмани мозг вкусомКостя Павлов
Переглядів 2,4 млн
Бабцю КИНУЛИ росіяни! Місцеві не знають де її армія РФ. "А кто нас защищает?"Ми - Україна
Переглядів 419 тис.
Буданов про плани на Курську область, та Воронеж #shorts #курск #воронежАпостроф TV
Переглядів 2,4 млн
Удар по російській колоні в Курській області #shorts #війна #курськ #арміярфBBC News Україна
Переглядів 827 тис.
ВСУ наступают под Курском. Путин требует действий. Эвакуация в Белгородской области. НОВОСТИРадио Свобода. Новости
Переглядів 2 млн
а ты любишь париться?KATYA KLON LIFE
Переглядів 2,7 млн
Kabağ hiç böyle pişirdinizmi! İnanılmaz lezzetli #kabak #yemek #un #domates #tarif #kahvaltıGÜLSÜMÜN SARAYI TV
Переглядів 6 млн
Just Conclusion of above video:: [For beginners only]
there are basically two kind of execution
1. Sequential (Default)
2. Concurrent(achieved with async{} )
For instance if we have two function func1() & func2(), execution of func2() is dependent on func1() then in that case we can use default version of coroutine and if they are independent of each other then we can use concurrent with the help of async{}
with the sequential execution we run the code sequentially so if func1() takes 5sec for execution and func2() takes 3 sec for execution then total elapsed time will be around 8 sec, however when this methods are independent and their results are not required for execution of other fun then in that case execution can be completed in 5 sec with the help of async(concurrent).
Async vs launch:
Async returns Deffered [Type:: calling function is returning]
launch returns Job.
await() -> methods are used to ensure the execution will go further until function is executed completely. [e.g func1().await()]
We can also call async with LAZY pass below value in async constructor.
val one = async(start = CoroutineStart.LAZY) { func1()) }
one.start() // start the execution of func1
Reference link:: (Highly recommended: please watch this video before exploring below link)
kotlinlang.org/docs/reference/coroutines/composing-suspending-functions.html
You are repeating a very incorrect statement that gets thrown around a lot with coroutines.
All coroutines are sequential.
What produces concurrent code are nested coroutines.
Async does not produce concurrent code without nesting. It just returns the value.
You decide how the code is blocked depending on where you put the .await() or .join() functions.
@@Ilamarea correct
This is the easiest explanation I've found on Kotlin Coroutines. Very, well done. 👏👏
This video should have been extened to show how you would have updated a UI component with the data returned by the async function (in a thread safe manner)
whenever I starting watching your videos.I just press the like button first. :). Thank you for such simplicity
Thank you so much 😀
I've read a whole bunch of blogs and posts and watched a ton of videos.
This is the first thing that actually explains the difference between launch and async.
Nice.
So I just watched the entire series (except android specific things because I don't make android apps) and I really helped a lot. I finally understood those thingies.
I knew the async mechanics from other languages like Dart and a bit of JS but I had hard time mapping the Kotlin syntax to what was used to.
This did really help.
Omg where was you .. seriously u made it so simple for me.♥️
Thaaaanks❤️
I love all your videos!!! I am still shock why still not enough views. This is quality content to be honest.
Thank you!! ❤️ I think that's completely normal that UA-cam needs its time to check who is actually serious with his videos and who not. In the long term my channel will grow
@@PhilippLackner I really hope it will. keep it up! Will wait for your more videos!
@@jayceeddeyro1406 thanks man, I will just keep going thanks to comments like yours🙏
Hey man, would it be okay for you, if I use your comment as one of many testimonials on my future website?
@@PhilippLackner Yes of course! I am okay with it. Its my pleasure! :)
Neat explanation, understood the concept right away. Thanks!
Glad you like it!
علينا النعمه اسيادنا راضيين عليك Good Job dude really thank you very much
your coroutine series is the best Period
you made coroutines so easy
Great Explanation
Thanks Philipp for this ease and fully clear content ❤❤❤❤❤❤
Very well explained man
Thanks man!
Thanks for such a simplified, great tutorial :D Keep going, Also please make a tut about Dependency injection , Thanks
Very cool session. Thanks for this 👍
Glad you enjoyed it!
Fantastic video. Keep smiling and keep rocking.
Nicely explained. Thanks.
Thanks :)
Nice explain..
great content Philip, you are awesome
thank you. understood fast
The best explanation. TY
Great tutorial which was helpful to me as a beginner, will be implementing this later :) thanks
You're very welcome!
I'm coming from web and my understanding is Deferred = Promise
it is better to explain more if you try
val answer1 = async{networkCall1()}.await()
val answer2 = async{networkCall2()}.await()
the result should be different.
then they would give answer sequentially rather than parallelly
@@VivekSharma-qw5ky Why it is so? Only the Deferred object run at the same time?
Thanks for the videos!
You're welcome!
great video so far , keep up the good work
Thanks man🙏
i already knew little bit about coroutines before but after watching your videos , they are not that long but showed me valuable information and i will keep watching your videos , thank you
Good Job. Explained it very well.
Glad it was helpful!
thank u for your wonderful tutorial
Thanks bro!
super clean explanation
very well explained.
thx for the best simple exapmles
Thanks for the tutorial!!!!!!!!!!
Thank You
Very nice 👍👍, you are simplyfying it very good
Your all videos are just awesome .please create a udemy course on Android advanced topics please
Thank you sir for your help
Always welcome
gud content. i like it
well explained!
Hey please make a video on how to consume GraphQl api with Apollo using MVVM and coroutines
Nice Idea !
Thanks for the suggestion
great tutorial
Thanks!
Looking forward for your new udemy course
thank you, Philipp but i did not get why we should use await?
Here still i'm not clear why i should go for async when i can able to make both requests in 3 seconds using launch().
I guess because with async you have a much leaner code...
How will u do it?
wow
It reminds me Javascript again..
async await..
Does the await call block until it finishes? So do we wait longer if network call 1 takes say 10 seconds? And only then we see call1 and2 (which took only 3 seconds)?
amazing!!!!!
mantap bang messi
why did you hve to use globalscope coroutine? would we be able to do this without the global scope coroutine?
I'm in a fragment and after onCreate(), onCreateView() is called, the problem is that I need the data retrieved from the service in onCreate to use it in onCreateView, but what happens is that the code keeps going and crashes, the problem is that it has no data because is being obtained in the corrutine in onCreate, like your method. How can I wait for corrutines to retrieve data before continuing to onCreateView()? Hope I made myself clear, thank you!
Is Deferred in kotlin and Future in flutter are same concepts?
WorkManager Tutorial please
Next project will be a bigger app, maybe after that
:) Thanks
You're welcome!
Why do we require to use GlobalScope.launch? Can we not write the coroutineScope {} ?
Why we should use async instead of launch?
👍
What about using viewmodel scope launch?
When I use it is not necesary use async and await
brilliant..but is there any use case for one "async" alone ?
CONTROL + D !!
I think the async will create 2 separate threads and wait for it, in that case what is the use of suspend? In first way coroutine scope will run in a single thread for both network calls? I'm new to kotlin , someone please correct me if I'm wrong? How can we track how many threads are getting created, some good resources to read will be appreciated.
What is the meaning Deferred?
one question, as you asked to ask- on your label picture of the channel at the video beginning (where a green android is)- the word "ANDROI" - is something like hand, "D" - is a body. But I am still confused what "EVS" is?
PS. Videos are great, thank you)))
Uhm read my name again and then look at the logo again😂
hi sir in the case when you use two launch functions you said we need to wait for both jobs to finish so the we don't see null for answer1 and answer2 .why !?
GJ as always is there any chance to make a video about web sockets?
Not planned currently, but someday I want to do something with client server communication
Hi btw what imports you have in your project? Becuse i cannot use some methods/functions that you use for the video on my android kotlin
project
Can you please make videos on Dagger because it's really hard to implement in real-life projects.
this is very different from javascript async await, I was thinking the await() function will block the code execution until the async function completes, in fact this is opposite
Make video about dependency injection took thank you in advance
Check out my running tracker app
Hi,
Thanks for your videos
Why did you change from val to var and back to val
Why cannot all your variables be var for the demos (unless you want to declare a constant, like the TAG during the program that does not change, and will not change) ?
For example - time = 04:48, var answer1 , val job1 turns to val answer1 @ 05:12
Only ever make a variable a var if you need to change it, everything else is a bad practice and is also marked by the IDE as a warning
@@PhilippLackner many thanks (peter?)
Tried using async and it said to include anko library and when did async was deprecated.
You said its bad practice but you did not mention why it is bad practice. Can you explain that ?
Is it correct to use delay to simulate network calls instead of sleep? Because in fact network requests are blocking in common cases.
Network calls don't block the thread if you use them in coroutines
At 4:35 (the bad way) it took 3039 ms but in 6:41 (the better way) it took 3091 ms. Why?
what if i didnt call await ?
Can we have 1 more video for async await??
What didn't you understand here?
At 4:49 : why is this a bad practice?
+
bibi aku cantik banget bang