-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💭 How to support pagination with this? #12
Comments
@nihk can you please help here? |
hi @Meet-Miyani. i'm not familiar with the androidx.paging library, unfortunately. in my opinion, it's a library one should avoid using unless your use case is handling hundreds of thousands of records in a database table. but to your question: upstream the UI can call in |
I see, seems a bit difficult for me @nihk But I'll give a sure try! Thanks for considering my issue ❤️ Again thanks a lot. If you don't mind can I reach back to you in case I couldn't figure it out? |
no problem. let me know how it goes! |
Hey @nihk , seems like it did work, but still I am messing up something, maybe with concatenation of old and new data. I've taken pageSize as 5 for checking it faster. Will increase it later Let me show you the code changes, VideoDataRepository
ShortVideoDataRepository
ShortsFragment
VideoPagerViewModel
|
i think in
|
i'd forgotten about the |
this part shouldn't be in the also in hindsight, avoid duplicating the variable name adding something like this will probably work:
|
might want to use flatMapConcat instead of flatMapLatest too, to avoid accidentally discarding downstream event processing |
another approach instead of the above is to manage the current page state within your VideoDataRepository implementation, and simply call something like VideoDataRepository.nextPage() when desired conditions are met in |
I see, sorry to come up again. I am really naive with the flows and the architecture you implemented in this. Thanks again for helping this much 🙏🏽
See, here
Check the logs, seems like it is able to load the next page results, I guess.
|
Hey @nihk, please help here brother! |
Hello @nihk is there any update? If you have some free time, I will appreciate your help here, Thanks! |
🤔 How to support pagination with this?
I am trying to fetch the videos but with pagination. And I already setup required things, but not sure how to fit it in the end. As I find this code a bit complex architecture to understand. I don't have much experience with flows.
What I did for paging is:
Now problem here is, in the code there are many things which are shared in a flow, which extends ViewResult, I am referring to the
VideoPagerViewModel
, according to the code I am able to use Flow<List> but according to my implementation I will be getting Flow<PagingData> this is where the issue is happening, I can't make the PagingData extend ViewResult directly also. So how can I achieve the pagination in this? Because in ShortsFragment I can see that code fetches all the videos at once.ShortsFragment (🗝️ Already Present)
VideoPagerViewModel (🗝️ Already Present)
VideoDataSource (🆕 Added)
PagerPagingAdapter (🆕 Added)
The text was updated successfully, but these errors were encountered: