Hey Philip. This is by far the best vid to understand flatMap operators. Some comparisons for easy understanding collectLatest is similar to flatMapLatest , Buffer is similar to flatMapMerge , normal flow with different operators is similar to flatMapConcat !
About flatMapMerge: The same discouragement is applied to flatMapConcat too. flatMapMerge just collects the flow concurrently, i.e. emits them as soon as they are available. So there is no preserved order. Additionally, it takes concurrency value as an argument: concurrency: Int = DEFAULT_CONCURRENCY The default concurrency value is 16 but it can be changed in the JVM too. Also if we will pass 1 as a concurrency argument, it will behave the same way as flatMapConcat.
Great video, really helped me to get into the different indications of using different operators. Got triggered by how you pronounced "dessert" but that just helped me focus more :-D Keep up the great work!
Hey thanks for the video. I disagree that flatMapMerge is less used and is not recommended. If order does not matter and all you need is just a result, this operator comes into play and can even be more efficient
Hi Philip , could you explain callbackFlows with Retrofit api calls, I have a UseCase (which behaves as an executor) talking to repo to make api calls , problem is it has a success failure callback , and through this callback only viewmodel understands the Success and failure of api
No, a single recipe is coming in as a flow, not as a recipe. That flow emits multiple values: first the single recipe from the DB, then the recipe from the API. And you want all recipes as a list in a single flow
@@PhilippLackner oh okayy. Since the return type of the mapping function will return a flow that needs to be collected, we'll use flatMapConcat. Gotchaaa
Kind of, yeah. Flows already have the natural backpressure mechanism that they will only emit if the collector finished collecting. With buffer() and conflate() you can change the way this is happening which can lead to faster execution in specific scenarios :)
@@PhilippLackner It would seem to me that a good application for conflate would be say, some sort of status update, and rather than have to process each individual update (assuming they aren't incremental updates), you discard in favor for the most recent. For instance, I have 3 stock market changes, and I only run the code to update the status on the most recent of the three.
Hi Phillip first of all thank you for your Videos Please tech us how we can multiply 4 number in kotlin lets say we have 2 textNumbers = car price month outputs for user when it click on button it shows this 3 textviews = downpayment processing fee monthly fee 1 button = shows all 3 text views formula is > val balance = 0.60 val intrest = 0.013 val downpayment = 0.40 val proccessing = 0.55 val f1 = carprice * balance * interest * month downpayment = car price * downpayment monthly fee = (car price * balance ) + (f1) / month processing fee = car price * balance * processing fee
I have a question, If I have multi request in flow and a request response failed ,what is the result final? Example : getRecipeById with 5 request ,but one in 5 request response return fail.
i gotta say, the "restaurant" example at the end was super helpful to understand this. Props
One of the best series and explanation I ever come across regarding flow. You simply nailed it man.
The dinner example was genius, thank you very much.
I had no idea about flatMap, buffer(), conflate().. good stuff!
By far your videos are the best online source that I found to learn Android Kotlin and compose , clear and direct,,,, keep it up Philipp 👍🏾
Damn couldn't have been a better explanation of conflate and buffer than this one. Thanks dude!
Thanks!
I just want to let you know that example with eating was brilliant. Keep up!
Hey Philip. This is by far the best vid to understand flatMap operators.
Some comparisons for easy understanding collectLatest is similar to flatMapLatest , Buffer is similar to flatMapMerge , normal flow with different operators is similar to flatMapConcat !
The dinner analogy was a very good one, extremely helpful ! Thank you.
Can you Please make a series like these on dagger hilt?
About flatMapMerge: The same discouragement is applied to flatMapConcat too.
flatMapMerge just collects the flow concurrently, i.e. emits them as soon as they are available. So there is no preserved order. Additionally, it takes concurrency value as an argument:
concurrency: Int = DEFAULT_CONCURRENCY
The default concurrency value is 16 but it can be changed in the JVM too. Also if we will pass 1 as a concurrency argument, it will behave the same way as flatMapConcat.
Very clean explanation, keep rocking. Thanks
Thank you Philipp, it was easy to understand by watching your videos
Glad it was helpful!
This video is very helpful. Thank you very much.
Pretty good explanation with the restaurant) Thank you!
Really great tutorial series. Helped me a lot! thanks you
Hi Philipp, Great topic, can't wait to see the third video, well done
Coming soon!
as it's complex but you make it easy for us. thank you
Really great tutorial series. Clear and concise, has helped me a lot, thanks
This is a sample of a good tutorial thanks
Great video, really helped me to get into the different indications of using different operators. Got triggered by how you pronounced "dessert" but that just helped me focus more :-D
Keep up the great work!
Sheesh! That's tough, especially flat mappers. But other things..mooostly make sense! Just some practice is needed.
Awesome examples! The explanation is very clear, thank you
Really great tutorial series
nice explanation.
nice video thank you always Philipp! I would also love to know how all these are applied in the real project!
Thanks Philipp 👍🇺🇦
Didn't know what the fold method did until now 👍🏾
👨🏻💻 Great job bro
just great as usual !
Overall, great tutorial quality Philipp. I really miss more actual use-case examples like shown at 16:00
Great teacher
Hey thanks for the video. I disagree that flatMapMerge is less used and is not recommended. If order does not matter and all you need is just a result, this operator comes into play and can even be more efficient
Hi. nice content.
with list also can use map.
val numbers = listOf(1, 2, 3)
println(numbers.map { it * it }) // [1, 4, 9]
any differentes or benefits?
Hi Philip , could you explain callbackFlows with Retrofit api calls, I have a UseCase (which behaves as an executor) talking to repo to make api calls , problem is it has a success failure callback , and through this callback only viewmodel understands the Success and failure of api
For the recipes example that you have provided, we can also use the normal map function, right? I don't understand the difference in functionality.
No, a single recipe is coming in as a flow, not as a recipe. That flow emits multiple values: first the single recipe from the DB, then the recipe from the API.
And you want all recipes as a list in a single flow
@@PhilippLackner oh okayy. Since the return type of the mapping function will return a flow that needs to be collected, we'll use flatMapConcat. Gotchaaa
Loved the video. Does buffer() and conflate() operators have anything to do with the term "backpressure" management?
Kind of, yeah. Flows already have the natural backpressure mechanism that they will only emit if the collector finished collecting. With buffer() and conflate() you can change the way this is happening which can lead to faster execution in specific scenarios :)
@@PhilippLackner It would seem to me that a good application for conflate would be say, some sort of status update, and rather than have to process each individual update (assuming they aren't incremental updates), you discard in favor for the most recent. For instance, I have 3 stock market changes, and I only run the code to update the status on the most recent of the three.
Always best👍👍👍👍
Hi Phillip first of all thank you for your Videos
Please tech us how we can multiply 4 number in kotlin
lets say we have
2 textNumbers =
car price
month
outputs for user when it click on button it shows this
3 textviews =
downpayment
processing fee
monthly fee
1 button =
shows all 3 text views
formula is >
val balance = 0.60
val intrest = 0.013
val downpayment = 0.40
val proccessing = 0.55
val f1 = carprice * balance * interest * month
downpayment = car price * downpayment
monthly fee = (car price * balance ) + (f1) / month
processing fee = car price * balance * processing fee
I have a question, If I have multi request in flow and a request response failed ,what is the result final?
Example : getRecipeById with 5 request ,but one in 5 request response return fail.
nice. i follow all your video
If the emission is emitting many value in one second then how to collect one value and ignore all other values. Please answer Thank You.
Thanks bro
How to ignore all values within one second in Sharedflow. Please answer thank you.
Thank you
big thanx
Thanks!
Can you please make this it without using jetpack compose
?
How can we call multiple api call simultaneously using flow
golden
654th...Thanks Philipp
Ordering in a restaurant is a great abstraction.
Where is third video ?
Great video, but please increase your font size… it’s too small
hi, make tutorial about :how i encrypt app in android studio 🌷🌷 thanx
Great
bm - 13:02
So not major difference between collect{} and onEach{}
niceeeee
cool
Hey. Please create a series on KMM as well.