Take a good look at the current state of coroutines support in Android libraries and tools, explore some interesting and not-so-obvious edge cases when dealing with Kotlin code that includes coroutines and interop with Java, and briefly look at some new developments in Kotlin coroutines, namely StateFlow and its comparison with LiveData, and SharedFlow.
Resources:
Coroutines blog posts →
Coroutines 101 codelab →
Other coroutines codelabs →
Check out the 11 Weeks of Android website →
Related Playlists:
Languages – 11 Weeks of Android playlist →
11 Weeks of Android playlist →
Subscribe to Android Developers →
Speaker:
Manuel Vicente Vivo
#featured #android11 #11WeeksOfAndroid
Android Android 10 Android coroutines android coroutines tuto... android device manager android games android latest version android one android oreo android pie android studio android tips android tips and tricks android vs apple android vs ios android vs iphone AndroidOne async Coroutines how to manage async tasks how to manage async tasks in kotlin Kotlin Manage manage async tasks in kotlin tasks
21 Comments
It should be interesting to show also how to unit test it
You guys have made android tough to learn, can't you make it simpler
144p 📹
Good alternative for AsyncTask 👍
I am curious why your example observes LiveData or collects Flow directly in the Activity. Isn't it better to use a ViewModel?
How do you cancel a job via kotlin coroutines, in the same way you can do for AsyncTask?
For when you have AsyncTask instance, you have a choice, of canceling with and without interruption.
ON kotlin coroutines, I can see that you have to choose it when you create it. Is it correct?
I used to write Android apps on Java but two years ago I switched to Flutter on Dart.
And never regretted since then. Everything is so much easier in Flutter.
I remember how AsyncTasks first appeared and became recommended, now its deprecated… I'm tired of it frankly speaking.
Why should I learn Kotlin? Why should have created new programming language just for Android?
Kotlin is not used anywhere else
Snippet at 4:11 has an error:
Single.just(readFromDb())
.subscribeOn(Schedulers.io())
is actually equivalent of
Single.just(readFromDb())
.observeOn(Schedulers.io())
thus readFromDb() will be ran on the thread createWork is called(main?).
And it's not about RxJava, it's about Kotlin(or Java): to call a function(Single.just) we have to calculate its parameters first.
How can at the java?..Is it no way?! ㅠㅠ
Is it just me or in the first example the:
val dbData = readFromDb()
should've been "data"?
Looks like you are "uploading" to the remote server, the variable is called "data" and it isn't declared in the fun's scope?
So what is the rule for collecting flows in UI controllers? asLiveData().observe(..) when I want to observe hot streams as cold flows and lifecycleScope.launchWhenStarted when I observe e.g. database?
So… Use or not LiveData? Will there be a stable decision?
I wish Swift had coroutines
great video!
Making Simple way more Complex
Ugh my head goes 🤯🤯
Good bye java!
Great video! I am looking forward to learning more about coroutines
Android💚
good
So the live data and the flow (state, shared, channel, etc) will likely to coexist and won't converge?