Does below snippet considered as multiple streams?...
# orbit-mvi
m
Does below snippet considered as multiple streams? Also, is it currently possible to do this approach (in snippet)? Detailed in thread~
There’s a usecase in our apps to fetch 3 different APIs inside 1 screen, e.g:
Header 1
1. list item 1 2. … 3. list item n
Header 2
1. list item 1 2. … 3. list item n
Header 3
1. list item 1 2. … 3. list item n fetching this different list in parallel, also has it’s side effect for each service, e.g: empty state, loading animation, loaded animation
m
there’s nothing stopping you from doing that. However, please note that
collect
will suspend until the relevant stream completes. This means that unless you
launch
a separate coroutine for each
collect
call it won’t get past the first
collect
🤯 1
1
worth doing that on a
Dispatchers.Default
too so as not to overload the orbit event loop
tip:
coroutineScope { }
can be used in a suspending block for parallel decomposition
K 1
❤️ 1
🎉 1
🙏 1
to summarise ☝️
I’m not sure if the dispatchers are absolutely necessary, but just to be on the safe side 😉
m
ah, that’s great, thanks a lot for the code snippet example as well ❤️ K
found official docs from android regarding the parallel decomposition: https://developer.android.com/kotlin/coroutines/coroutines-adv#parallel thanks for take time to write the above snippet and giving us a hint to where should we look for references, especially the parallel decomposition part~ ❤️
🙏 1