Thanks to this, I used combine to conveniently merge the results in the method of sequentially calling multiple suspend functions and merging the results. Thank you!
@ernestguevara59687 ай бұрын
Thanks I needed a clean and quick explanation and demo of this for a code optimization. When ever I need android stuff I'd just search your name with the topic and probably you made a video about that!!! 👍👍👍
@Alchemist10241 Жыл бұрын
Philipps' tutorials make programming so much easier and enjoyable
@itsic-marking31592 жыл бұрын
Like this format, simple, clear, no digression
@alekseyyakovlev69242 жыл бұрын
Isn't it better to use combine(flow1,flow2,flow3...) syntaxis for 3 and more flows?
@PhilippLackner2 жыл бұрын
Thanks to some comments I learnt that this exists😂
@federicocreti46992 жыл бұрын
This is true, I use combine(flow1, flow2, flow3). But thank to this video I reflected that maybe there are cases where the Philipp sintax is better. It maybe helps to divide some concepts of the flows
@mikeshin772 жыл бұрын
Your video lecture is really helpful! Thanks a lot.
@Camlon2 жыл бұрын
I was struggling a little in my personal project due to having multiple flows where some need to wait for another to finish and you came with a solution I didn't know existed. Thanks for another great video, Philipp.
@PhilippLackner2 жыл бұрын
Glad it helped!
@abada-s2 жыл бұрын
So combine will fire when one of two flows emits a new value Zip will fire when both flows emit new values Merge will listens to all flows that we pass to it and collect every value from any of them
@haykmkrtchyan709311 ай бұрын
For combine we can use also something like this val resultFlow: Flow = combine( _flowOne, _flowTwo, _flowThree, ) { flowOne, flowTwo, flowThree -> flowOne.length > 10 && flowTwo < 20 && flowThree }.stateIn( scope = viewModelScope, started = SharingStarted.Eagerly, initialValue = false, ) Merge just accepts flows with the same type, whereas combine can accept flows with different types. Zip is more similar to combine than merge, hence people tend to think that merge is more similar to combine 😁
@enikebraimoh2 жыл бұрын
Been waiting for this 💯💯🔥🔥
@miladhashemzadeh56262 жыл бұрын
Another Gr8 gr8 gr8 toturial by phillip
@TheMikkelet7 ай бұрын
Practical uses for Zip is when you're waiting for several asynchrounous functions to finish (such as web requests), and you only want to continue when all of them are done
@damorpl2 жыл бұрын
There is also a standalone combine function that takes multiple flows, similar to merge. Just in case someone needs that.
@jpdsah2 жыл бұрын
we can also overload the combine function so that any numbers of flows and any type of flows can be combined together
@princeneo294 Жыл бұрын
@@jpdsah yeah, I actually did this in a project that I'm working on
@tmjromao2 жыл бұрын
Hello Philipp, many thanks for the clear explanation. Top! Could you do video explain your prefered way to load the data model layer from a JSON file? This is so easy, and common on iOS. Did found a how to explanation for a Jetpack Compose project. Much appreciated. Best!
@CivoMT2 жыл бұрын
Best straightforward explanation out there. Thnx a lot :-)!
@PhilippLackner2 жыл бұрын
Thank you!
@amateur_gamer1012 жыл бұрын
Thank you for this.
@Rashilamba-iz4ii Жыл бұрын
Thanks
@jeckonly58532 жыл бұрын
Though i don;t have time to watch yet, I come in to click the like button first🥰
@CitizenWarwick2 жыл бұрын
Hey Philip thanks for that, I was hoping you might show how to combine flows and use the result of the first flow as arguments to the combined flow. I had a situation where I wanted to do this and could not figure it out :( any ideas?
@PhilippLackner2 жыл бұрын
Isn't this what I showed?
@CitizenWarwick2 жыл бұрын
@@PhilippLackner maybe I'm not explaining correctly or missed something Imagine you have a flow but you want to combine a second flow however you need the result of the first flow to use as arguments to a function that returns the second flow you wish to combine, hope that makes sense!
@illyaevseev3122 жыл бұрын
@@CitizenWarwick val argumentFlow = (1..100).asFlow() val flowResult = argumentFlow.mapLatest { " -> $it" } combine(argumentFlow, flowResult) { arg, res -> "$arg$res" }
@MrDefiler82Ай бұрын
in the example with combining three states can I use filter ? for example isAuthenticated.filter { it == true }.combine(user) { user -> user }.combine(posts) { user, posts -> .... }
@alekseirozhnov30382 жыл бұрын
Hi Philipp! Love your videos. I found one issue with the approach you covered in this video and I am unclear about possible solutions. Maybe you could shed some light on it. The issue is that when you launch the combine in viewModelScope it combines the flows asynchronously, however, there are many cases where you'd want to get a synchronous result of combining multiple flows. Here is a simple example: * 5 text fields where user enters a number * each of those fields has a mutable state containing a number entered * there's a text field where you want to display a sum of all numbers entered. When using combine().launchIn() approach the resulting sum will be displayed with an unnecessary delay caused by a launched coroutine. In this case, it would make sense to combine states synchronously. i.e once the state of an individual field is updated, the resulting state must be updated immediately. A more relevant example might be having a draggable element on a screen. If you wanna use the dragging position to combine with other states. You could observe dragging state and resulting combined state separately in your view to avoid dragging delay. However it would be so much nicer to just observe 1 stateflow from ViewModel which would be the combined state. Please let me know if you have an answer in your mind :)
@ilyastoletov Жыл бұрын
try cachedIn() instead of launchIn()
@mustafaammar5512 жыл бұрын
very cool video thank you BRO👍👍👍
@pumaelgatosiberian50472 жыл бұрын
offtop but I cant find answer, Philipp, tell me please, if my screen contains bluetoothadapter, bluetooth callback etc where should I store it? If no fragments, just Activity with navhost. May be you will do some video with such a content, google don't know about how to do it, thanks in advance!
@Shriharshpathak5 ай бұрын
So, technically, even though we are able to combine more than 2 flows, they won't run concurrently. RxJava's zip can combine upto 4 concurrent API calls...
@ChrisCologne842 жыл бұрын
Philipp do you use ExperimentalApi's in production?
@gulfappdeveloper28492 жыл бұрын
very useful video
@AzadKumar-zi5lm2 жыл бұрын
sir, can you make video on full guide to flow start to end point ✅
@Rafael-hk9pg2 жыл бұрын
Great video, thanks a lot. How can I get a SavedStateHandle object into a MutableStateFlow?
@PhilippLackner2 жыл бұрын
Use the latest lifecycle dependency, then you can call getStateFlow in the saved state handle
@federicocreti46992 жыл бұрын
What is different of use flow.combine(flow2).launchIn(........ Or combine( flow1, flow2, flow3 )..... ?
@pumaelgatosiberian50472 жыл бұрын
very helpfull!
@sikka092 жыл бұрын
Hello sir, can you create a video about implement text prediction for custom keyboard app.i search every where in the internate but i cant find any good tutorial.
@joko_pryn2 жыл бұрын
Reactive programming ❤️
@vigneshkarthi33212 жыл бұрын
Bro how to build video player that need to support all video format.
@RafaelRunaway Жыл бұрын
how about reduce function?
@udhdbdjxisskka7 ай бұрын
So what's the difference between combine and merge? Doesn't seem to be any?
@jopadjr2 жыл бұрын
387th...Thanks Philipp
@sh3r1p492 жыл бұрын
✋
@kirwakelvinkering3122 Жыл бұрын
I think the concept of what flows mean should not be taken so lightly ,i find it challneging.Thanma Philip for this ,however ,we request you yo make another tutorial on the same where you will demistofy it once and for all .Kind regards.