Replies: 1 comment 1 reply
-
You can find remi's take on pagination here, then here's mine. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a couple of endpoints that return paginated data, the pagination model is the same but the list of the content is a different type for every endpoint, so I have something like this.
I have a couple of screens with list that reads this paginated data, to manage that I'm using 2 main pods
In the UI this notifier is listened and every time the user is getting to the last item in the page the
loadNextPage
is triggered, that's the general flow for the pagination logic, the issue I have is that I have a lot of pages that use pagination for different models and now I have a lot of thisfirstPagePod
andModelPaginated
notifier classes, where the only difference is the line inside the build that gets the first page, and the line inside theloadNextPage
method that fetch the next page.I though on doing this with a family but it becomes complicated to handle all the conditioning to use the right pod for the first page and using the right call for the next pages.
I also though on creating some base class that the Notifier could implement or extend but its complicated with the same thing, fetching the first and next pages.
The last thing I though was to convert this in an interface and have two abstract methods
fetchFirstPage
andfetchNextPage
and create new notifier classes that extends of this one, but I don't know this is the right approach and I don't know how to enforce to never use this base pagination notifier and enforce the override offetchFirstPage
to usewatch
to allow the notifier to rebuild itself, and other issues.For example, the last idea move me to create something like this
but this trigger the
notifier_extends
warning, and if I remove the@Riverpod
annotation it will not inject the pod.I also though on removing the
@Riverpod
annotation from theBasePaginatedNotifier
but that will remove the access to thestate
andparams
propery in the base class making theloadNextPage
not working, or needed to override, and it it will be overriden then it doesn't make sense to have this base class, because thats the logic I want to reuse.could you point me in the right direction? if I'm doing this right or maybe I'm complicating my self and there are more easily approaches.
Beta Was this translation helpful? Give feedback.
All reactions