A really good way to show an example and finally someone who actually knows the meaning of "beginners". Just recently started learning Kotlin and couldn't understand how coroutines work. This one is the best explanation possible for that, literally. Thanks a lot.
Wow. This is like the simplest detailing someone can offer on Coroutines. I implemented it yesterday reading some other blog. I had my doubts still. Now it's all sorted. Thank you.
As a result of watching this video four times to fully understand the concepts of coroutines, I have successfully run a piece of code which for the past week kept crashing. This also works for normal Kotlin code outside of Android. Once again, thank you for sharing this video and explaining how coroutines work.
i've been reading several blogs and documentation, but this is just one video that made it look all so simple. thanks for the awesome video. Hope you keep churning out more of them.
Thanks for making this video. The task of making sequential requests based on network responses drives me crazy! Thanks for this excellent video. I really appreciate it.
This is very useful tutorial on running a "multi threaded" application in Android and Kotlin using Coroutines. Very well explained. This is better than Async and other thread related concepts. Thank you very much for sharing. You have explained in 23 odd minutes a concept I have previously not understood in spite of spending hours on tutorials and other videos. Much appreciated.
It's been a while since I watched a tutorial that is not "copy this code and it will work". I fully understand something that I tought it was really messy. Thanks a lot man!
Great! Next timer I think it's better to run the coroutines in the lifeCycleScope or scope one to the current activity/fragment or even better the viewModelScope :)
At 0:29 to 0:32 you say RxJava is used for performing background tasks. I think this is a bit of an understatement. Thread switching is just one part of RxJava. There are hundreds of other operators present in RxJava that allows other functionality besides just Thread Switching. Just wanted to let you know so that thousands of others can benefit. Best part 7:00 to 7:45 The visual representation of thread and co-routine. I watch your content frequently and its absolute quality. Keep up the good work.
Pretty sure I also said that RxJava has powerful operators. I meant when compared to coroutines. When comparing coroutines with RxJava you're strictly talking about threading. Although thats changing. Looks like coroutines also has operators now and will continue to get more.
Superb Mitch, your way of explanation is too too... awesome in shot span of time with perfect example. Keep it up i watched all your lectures over android.
Thanks for the tutorial, the way you showed how coroutines work is intuitive. Love your English, it's so clear for non-native English speakers. Thumb up and new subscriber to your channel. Greetings from Mexico.
Actually this is really impressive, you explained Coroutines in a direct and easy way which is probably more complex than understanding Coroutines itself! Great job man!
Hey Mitch, just tried it myself. Great tutorial, it cleared up my understanding of suspend functions. I was under the impression that delay() would suspend each suspend function and not the entire coroutine. Thanks for clearing that up!
I like the way that you explain ,whenever i got problem in android concept and implementation i check whether you put something about it on RUclips or not. thank you very much
You are awesome and main thing with every video is you zoom the most important part which I liked the most. Also you explain in layman terms where one can easily understand and implement. Thank you so much this video tutorial helped me a lot.
I don't know if you mention it in another Coroutine presentation but there is one other difference between CoroutineScope() and withContext(). CoroutineScope() returns a job object withContext() returns the result of the suspend function. So where you would need to use job::invokeOnCompletion() in order to access results you would be able to direction access the result using withContext()
First time watching one of your videos. Been working in Kotlin for awhile, but completely new to Coroutines. Nice beginner introduction. Would be interested in viewing a series on Coroutines, i.e., how to cancel them, etc. Maybe even something on Flow, etc.
Quick and interesting question: On 18:37 you say that withContext switch the context of the coroutine. Does it actually do that or it changes the coroutines itself?
I really like this tutorial. Very easy to understand and it cleared up a lot of questions I had. 👍. It really puts in perspective the actual difference between coroutines and threads, which is so important when making reactive and resilient software applications.Thank you!
I really hate Kotlin Coroutines and prefer RxKotlin/Java (Reactive Programming), But this video does a good job of explaining and making it more interesting. I use Coroutines for Ktor only.
I was confused about 22:12 part. Like how does it _wait_ for result1 and then goes to result 2. So I looked in to _delay(time)_ method. What happens is that the delay method pauses the execution of the coroutine in which it is called for the given time, and then resumes it. Keep in mind that the coroutine is not a thread, which is why delay causes only the coroutine to pause and not the thread in which it is running.
Thanks for the great explanation! Simple, somewhat unrelated question that I am too dumb to google apparently: How are you setting the onClickListener for the button without linking the button through findViewById first? Am I missing something obvious?
Hey Mitch, great tutorial, I have one doubt though, At 21:26 , the fakeAPIRequest function calls getResult1FromAPI which runs on the background thread, however, we are switching the context in setTextOnMainThread. Won't the getResult2FromApi be called on main because we did not switch the context back?
Thank you for the simple tutorial. Wanted to replace AsyncTask, since it is now deprecated, and this seems great! It will actually look better than the code i had.
Thanks, this has really been a nice lesson on coroutines. As this is my first encounter with kotlin and coroutines I am wondering what's the difference (sth. happening in the background) choosing IO or default...
Hi Mitch, I used your method of using Coroutines to implement a timer, for short duration it was accurate but for longer duration lets say 30 minutes it was lagging behind by 4 seconds
5:18 : The explanation of suspend keyword seems inaccurate. You said the suspend keyword means the function can be used in a coroutine, and if we remove suspend then you can't use it in a coroutine. I think it should be that, suspend means the function can ONLY be used in a coroutine, and if we remove suspend then it becomes a normal function, and can be called from anywhere (coroutine or not)
Thanks a lot for this tutorial. Want to know on which thread getResult2FromApi is getting executed. As you mentioned coroutines would navigate to the thread mentioned in the CoroutineScope. Just before invoking getResult2FromApi, main thread resumed for setting result of getResult1FromApi.
Coroutines, another strong reason to shift from Java to Kotlin
Thanks for the video
Yeah very strong. And this is just the surface of what it can do
Hi, i think im late here, but i need to ask about your statement. So, java cant use coroutines?
@@Sam-si7xv nope
@nero I don't know y someone will use asynchronous task now instead of loaders or executors🙂
@Saptarshi Samanta 1 year later, but yeah you can use kotlin with asynctask
Finally, an easy way to understand coroutines, thank you, helped me a lot
There's a lot more to it. This is a very very brief introduction
A really good way to show an example and finally someone who actually knows the meaning of "beginners". Just recently started learning Kotlin and couldn't understand how coroutines work.
This one is the best explanation possible for that, literally.
Thanks a lot.
Wow. This is like the simplest detailing someone can offer on Coroutines. I implemented it yesterday reading some other blog. I had my doubts still. Now it's all sorted. Thank you.
no problem brother
As a result of watching this video four times to fully understand the concepts of coroutines, I have successfully run a piece of code which for the past week kept crashing. This also works for normal Kotlin code outside of Android. Once again, thank you for sharing this video and explaining how coroutines work.
I always findmy self landing in your channel when ever I searched any issue. Thanks
i've been reading several blogs and documentation, but this is just one video that made it look all so simple. thanks for the awesome video. Hope you keep churning out more of them.
Always churning brother
Just love the way he explains everything
Thanks for making this video. The task of making sequential requests based on network responses drives me crazy! Thanks for this excellent video. I really appreciate it.
This is very useful tutorial on running a "multi threaded" application in Android and Kotlin using Coroutines. Very well explained. This is better than Async and other thread related concepts. Thank you very much for sharing. You have explained in 23 odd minutes a concept I have previously not understood in spite of spending hours on tutorials and other videos. Much appreciated.
It's been a while since I watched a tutorial that is not "copy this code and it will work". I fully understand something that I tought it was really messy. Thanks a lot man!
Mitch, you are the best teacher of android on RUclips, keep it up.
Thanks pal
Great! Next timer I think it's better to run the coroutines in the lifeCycleScope or scope one to the current activity/fragment or even better the viewModelScope :)
I watched many tutorials and it was so confusing. your tutorial made it very easy and now I think I can start using it.
Thanks a lot.
I read quite a lot about coroutines. This video is top notch at explaining it all. Well done and thank you!
Nice explanation but small correction at 13:16 . Main, IO, Default these are the three co-routines dispatcher not scope.
Better than the google tutorials, seeing the coroutines in action is way more simple to understand than abstract explanations. Thanks!
At 0:29 to 0:32 you say RxJava is used for performing background tasks. I think this is a bit of an understatement. Thread switching is just one part of RxJava. There are hundreds of other operators present in RxJava that allows other functionality besides just Thread Switching. Just wanted to let you know so that thousands of others can benefit.
Best part 7:00 to 7:45 The visual representation of thread and co-routine.
I watch your content frequently and its absolute quality. Keep up the good work.
Pretty sure I also said that RxJava has powerful operators. I meant when compared to coroutines. When comparing coroutines with RxJava you're strictly talking about threading.
Although thats changing. Looks like coroutines also has operators now and will continue to get more.
CodingWithMitch Yea, every now and then we have something new, thats the fun I think.
This was all I needed to get started with Coroutines. Thank you!
One of the best video to understand kotlin coroutines
Superb Mitch, your way of explanation is too too... awesome in shot span of time with perfect example. Keep it up i watched all your lectures over android.
Your way of explaining things is very unique, RESPECT.
Thanks for the tutorial, the way you showed how coroutines work is intuitive.
Love your English, it's so clear for non-native English speakers. Thumb up and new subscriber to your channel. Greetings from Mexico.
Thanks from Canada 😬. Glad it helped you.
Actually this is really impressive, you explained Coroutines in a direct and easy way which is probably more complex than understanding Coroutines itself! Great job man!
Hey Mitch, just tried it myself. Great tutorial, it cleared up my understanding of suspend functions. I was under the impression that delay() would suspend each suspend function and not the entire coroutine. Thanks for clearing that up!
I like the way that you explain ,whenever i got problem in android concept and implementation i check whether you put something about it on RUclips or not. thank you very much
Any Android developer worth his/her salt will really appreciate coroutines. This is going to make our life much more enjoyable as Android developer.
You are awesome and main thing with every video is you zoom the most important part which I liked the most. Also you explain in layman terms where one can easily understand and implement. Thank you so much this video tutorial helped me a lot.
Zooming is important. I agree.
Thank you, I have gotten confused about coroutines until I find this video.
You're the best Android teacher. Thanks so much for your videos.
I don't know if you mention it in another Coroutine presentation but there is one other difference between CoroutineScope() and withContext(). CoroutineScope() returns a job object withContext() returns the result of the suspend function. So where you would need to use job::invokeOnCompletion() in order to access results you would be able to direction access the result using withContext()
Never understood Coroutines much better, thank you for the video.
Thanks for the very clear explanation - the best short video I've seen on the subject. Everything explained and no magical coding.
A big thumbs up for making it so simple to understand.
Love from a small developer.
I'm now super excited to browse through all your content, you kept it really simple and explained the concept quite well, thank you! And subscribed.
First time watching one of your videos. Been working in Kotlin for awhile, but completely new to Coroutines. Nice beginner introduction.
Would be interested in viewing a series on Coroutines, i.e., how to cancel them, etc. Maybe even something on Flow, etc.
Quick and interesting question:
On 18:37 you say that withContext switch the context of the coroutine. Does it actually do that or it changes the coroutines itself?
Excellent introduction to Kotlin and coroutines. You need to already understand threading.
I really like this tutorial. Very easy to understand and it cleared up a lot of questions I had. 👍. It really puts in perspective the actual difference between coroutines and threads, which is so important when making reactive and resilient software applications.Thank you!
Thank you! Simple and without long useless speeches!
Amazing work, man.
Me: Simple explanation? 23 minues? Naaah.
Also me 23 minutes later: Well, good job.
I don't like how you talk about AsyncTask and SQLiteOpenHelper
They're poop
@@codingwithmitch yes they are 💩
@@pembatamang8233 Also now the AsyncTask is deprecated.
Someone is getting offended
You both are so AWESOME :-)
Been waiting for this topic for so long. Now I am happy!
Corutines haveb been confusing to me until today. Thanks a lot.
Explained with a very detailed description. Thanks for the video
I really hate Kotlin Coroutines and prefer RxKotlin/Java (Reactive Programming), But this video does a good job of explaining and making it more interesting. I use Coroutines for Ktor only.
Really good introduction to coroutines. Thanks Mitch! Btw, nice t-shirt :)
I've understood everything. This is an excellent video!
I was confused about 22:12 part. Like how does it _wait_ for result1 and then goes to result 2.
So I looked in to _delay(time)_ method. What happens is that the delay method pauses the execution of the coroutine in which it is called for the given time, and then resumes it. Keep in mind that the coroutine is not a thread, which is why delay causes only the coroutine to pause and not the thread in which it is running.
Thanks for the great explanation!
Simple, somewhat unrelated question that I am too dumb to google apparently: How are you setting the onClickListener for the button without linking the button through findViewById first? Am I missing something obvious?
Android owes u a lot man...Great series...
Thanks for keeping us updated !
You are awesome, please don't stop making tutorials
Thank you for the Video.. You made Coroutine as easy as easy to understand for a beginner.!!!
Nicely explained, simple, and easy to get started.
Hey Mitch, great tutorial, I have one doubt though,
At 21:26 , the fakeAPIRequest function calls getResult1FromAPI which runs on the background thread, however, we are switching the context in setTextOnMainThread. Won't the getResult2FromApi be called on main because we did not switch the context back?
Thank you for the simple tutorial.
Wanted to replace AsyncTask, since it is now deprecated, and this seems great! It will actually look better than the code i had.
I absolutely loved your lesson on Coroutines. Thank you Mitch
the best video for a beginner. Thank you Mitch.
Thanks a lot this is the most clear and obvious explanation for Coroutines.
Thanks Mitch for explanation. Could you please make videos on Coroutines channel and Flow? I see very few videos out there explaining these concepts.
Please upload more on coroutines
Great job Mitch 😍
thumbs up before watching the video
i feel like im late to the party, but hey, this intro was really good! Thanks!
hey mitch please upload more examples of different cases of coroutines
may refer ruclips.net/video/x2QOzdh0Fqs/видео.html
i was stuck with an App that i had to use an API requests, you've saved me thank you
i shifted from java to kotlin bc of this. i couldnt handle rxjava :D you convinced me :D
Nice Keep on updating new videos. Here in India lockdown till 14 April. hope we learn in meantime from your videos
I'm also giving 20% off my Founding Member subscription until March 29. codingwithmitch.com/enroll/
Thank you. Today, I learn new thing in Android.
Wow your example is so simple and clear for me, I understand now
Thank you!
I saw other tuts, this one made it so easy to understand
Beautifully explained.... Sir you've got an Instant sub 😍
thank you for making it simple, i thought i could never learn coroutines.......
Thank you so much for your so didactic explanation about Coroutines. From now on I will be able to use it much better way. Thanks a lot again.
Thanks for the Easy understanding of Coroutine. I am expect more from you
Thanks Mitch...waiting for more videos...
Thanks, this has really been a nice lesson on coroutines. As this is my first encounter with kotlin and coroutines I am wondering what's the difference (sth. happening in the background) choosing IO or default...
I almost copied your code... but the app didn't crash as expected in 15:31. It wait 1 second to to update the textview.
weird...
For me learning android concepts means two channels:
1. Coding with Mitch
2. Coding in Flow
Thank you so much for this video, Helped a beginner like me a lot!
So simple and soft, thank u a good man for this lesson, I finaly gotcha
Wow, this is indeed very simple to follow.
Hi Mitch, I used your method of using Coroutines to implement a timer, for short duration it was accurate but for longer duration lets say 30 minutes it was lagging behind by 4 seconds
Amazing video Mitch, great work.
Nice example, now I can continue the Kotlin Adventure... C++ is still easier with threads
A much better explanation than on developer.android.com, where they included the ViewModel and distributed the code on multiple classes. Thanks!
Anything by Google is always over-engineered and explained in the most opaque way possible!
Dear Mitch ,can you please teach us delegation and delegated properties in kotlin?
Excellent video, very usefull, regards from Caracas, Venezuela
Thank you so much! It cleared my mind. Now I know better what is a coroutine!
Well done!!! Really liked how you did this!
Please make video on getting current location in activity and fragment (mvvm)
You can just use location manager developer.android.com/reference/kotlin/android/location/LocationManager
Whatever architecture is fine
5:18 : The explanation of suspend keyword seems inaccurate.
You said the suspend keyword means the function can be used in a coroutine, and if we remove suspend then you can't use it in a coroutine.
I think it should be that, suspend means the function can ONLY be used in a coroutine, and if we remove suspend then it becomes a normal function, and can be called from anywhere (coroutine or not)
Great tutorial, it's easy to understand and well explained
Thanks for the great video, beginner friendly and practical
I was just need that! thank you for the excelent explanation, best regards
A perfect example. Thank you so much!
Nice speaker , nice illustration.
Thanks Jimmy
Thanks a lot for this tutorial.
Want to know on which thread getResult2FromApi is getting executed. As you mentioned coroutines would navigate to the thread mentioned in the CoroutineScope. Just before invoking getResult2FromApi, main thread resumed for setting result of getResult1FromApi.
Good job. Well explained easily better than any other source including the awful Kotlinlang.org site