Hello everyone! I recently posted a new article called Jetpack Compose UI Architecture. Would be great to hear some feedback
It is dedicated to organizing and building complex features and flows using Compose, shows how to structure your code, handle user interactions while following State Hoisting and UDF
https://engineering.monstar-lab.com/en/post/2023/07/14/Jetpack-Compose-UI-Architecture/
๐ 3
๐ 1
๐๐ป 1
๐๐พ 1
๐๐ผ 1
๐ 6
d
dave08
07/23/2023, 12:30 PM
What do you do about keeping state for paginated items and Paging 3?
r
Roman Levinzon
07/23/2023, 1:40 PM
Sorry, won't be able to answer this properly since don't use Paging3. This library touches too many layers to my liking. I'd just listen to the lazy list state inside the coordinator and let ViewModel handle the rest ๐
d
dave08
07/23/2023, 1:41 PM
So what DO you use for pagination?
r
Roman Levinzon
07/23/2023, 1:48 PM
Have a data source that would return a Page of items based on the parameters such as page size and page number.
The ViewModel stores the items and last loaded page.
When user scrolls to the bottom, notify ViewModel and let it download the next page. Once loaded new items are appended to the existing list of items
d
dave08
07/23/2023, 1:51 PM
I see, I've really seen tons of people with creative alternatives for this issue, I guess this a another solution, but there's still the view position to handle when appending/scrolling, etc... It's a pity the Android team doesn't find a better solution (if there is such a general solution for all the common use cases...).
dave08
07/23/2023, 1:54 PM
What do you do when you have tabs that have sub-screens? One BIG UiState that becomes partials on the way down, A sealed class for each (+ a sealed class for the actions of each)? One vm and coordinator for each - or one for all of them?