bro, AsyncTask is not going nowhere, all what has changed is name and the way it works and executes in the background. AsyncTask is always there...and will be..
@@TheDnaitsirc Flow is a stable decision for repository and data source levels. Livedata is for View and VIewModel levels. StateFlow and SharedFlow are not stable yet but it fully replaces LiveData on mentioned levels.
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?
@@RhexGomez Yes, but it doesn't related to original argument, that LiveData look not relevant if you have proper reactive library. If we talking about databinding, it doesn't mean that with release of Compose in 1-2 years magically all apps who use data bindings are disappeared or rewrite all code to compose
@@gi1dor LiveData is lifecycle aware that makes it more efficient when being used in a activity or fragment. Foreseeing a library of lifecycle aware flow and channels, in case of no inbuilt support.
@@pavneetsingh4809 This sounds as repeating of some marketing, than actual argument. "lifecycle aware" just fancy words for subscribing and unsubscribing on particular lifecycle events, Flow not only lifecycle aware, it has structured concurrency which already works with Android lifecycle, and prevents leaks. Example from video about that LiveData unsubscribed on stop and resume on start can be implemented with 5 lines of code with Flow + LifecycleOwner. So no, it's not more efficient, it just has particular default behavior (which by the way not so easy to avoid)
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.
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?
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?
Either call "cancel()" on the CoroutineScope that starts all your coroutines, or call "cancel()" on a "Job"/"Deferred" returned by the call to "launch" or "async" But "cancel()" will not interrupt a blocking thread. It will only cancel a suspending coroutine.
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
It seems you took a long distance since you switched to Flutter. Anyways, kotlin isn't only for android, it's also used for multiplatform projects, you can have ios base code and create a backend with kotlin
Bye bye AsyncTask 😀👋 .... Hello Coroutines!!
I will still use Async tasks in Flutter
bro, AsyncTask is not going nowhere, all what has changed is name and the way it works and executes in the background. AsyncTask is always there...and will be..
@@shaun.august LOL. That's r/mAndroid stuff
@@shaun.august AsyncTask will be forever in our hearts
AsyncTask: I've moved to behind the curtain. :D
Thank you so much! It's time to migrate my livedata to flow!
saddd people are moving to flow etc etc and here i am learning livedata ....
@@no_one1500 Still valuable!
I am curious why your example observes LiveData or collects Flow directly in the Activity. Isn't it better to use a ViewModel?
Great video! I am looking forward to learning more about coroutines
So... Use or not LiveData? Will there be a stable decision?
For the UI layer? Yes. Anything else? No.
Not stable decision certainly. He says that in the video.
@@TheDnaitsirc Flow is a stable decision for repository and data source levels. Livedata is for View and VIewModel levels. StateFlow and SharedFlow are not stable yet but it fully replaces LiveData on mentioned levels.
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?
yep
So the live data and the flow (state, shared, channel, etc) will likely to coexist and won't converge?
I don't see any reason to use LiveData if you already use RxJava or Flow, except databindings (which I hope will be fixed at some point too)
Databinding might become irrelevant if we fully switch to Compose. Although it is too early to say that.
@@RhexGomez Yes, but it doesn't related to original argument, that LiveData look not relevant if you have proper reactive library.
If we talking about databinding, it doesn't mean that with release of Compose in 1-2 years magically all apps who use data bindings are disappeared or rewrite all code to compose
@@gi1dor LiveData is lifecycle aware that makes it more efficient when being used in a activity or fragment. Foreseeing a library of lifecycle aware flow and channels, in case of no inbuilt support.
@@pavneetsingh4809 This sounds as repeating of some marketing, than actual argument. "lifecycle aware" just fancy words for subscribing and unsubscribing on particular lifecycle events, Flow not only lifecycle aware, it has structured concurrency which already works with Android lifecycle, and prevents leaks. Example from video about that LiveData unsubscribed on stop and resume on start can be implemented with 5 lines of code with Flow + LifecycleOwner.
So no, it's not more efficient, it just has particular default behavior (which by the way not so easy to avoid)
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.
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?
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?
Either call "cancel()" on the CoroutineScope that starts all your coroutines, or call "cancel()" on a "Job"/"Deferred" returned by the call to "launch" or "async"
But "cancel()" will not interrupt a blocking thread. It will only cancel a suspending coroutine.
You guys have made android tough to learn, can't you make it simpler
Good alternative for AsyncTask 👍
It should be interesting to show also how to unit test it
Thank you, best man!!
How can at the java?..Is it no way?! ㅠㅠ
Nothing better than a new API to easily write gotcha code and break your app !
Making Simple way more Complex
Hello Coroutines!!!
omg... i am just understanding asynTask. It is now deprecated..
I wish Swift had coroutines
Dispatchers are simpler
Ugh my head goes 🤯🤯
Why?
me too
Excellent!
Oh ..
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
It seems you took a long distance since you switched to Flutter. Anyways, kotlin isn't only for android, it's also used for multiplatform projects, you can have ios base code and create a backend with kotlin
@@eliasb3857 does the backend language matter? You can create a backend on php, who cares, as long as it sends and receives the data
@@kirill4531 rofl, your statement was 'why they'd created a language only for Android'
Would have been nice if audio and video were in sync.
great video!
Nice bro tq
Tq bro
how are you
good
144p 📹
Get to the point, too much blablabla!
Good bye java!