Paginate is used for querying & paginating API responses. Paginate will
handle fetching new pages of data, and caches already fetched data.
TODO: Eventually:
Get an initial Pagination & Fetch Commands from a Config, the
requestData, Page Number, & a Pagination. This allows you to turn
Does nothing if the pagination has already
The Config type is used to build a Fetch Request, given the Paginated's
Request Data & a Page Number.
The result type of a Paginated Fetch Request. At the minimum, your API needs to return the items & a total count of all items.
Make a Config from a function that takes a list of Parameters & a Page Number.
Get the current list of items.
Get the current page number.
Get the total number of pages.
Get the total item count.
Return the current page's fetch request's error if it has one.
Return the Extra Request Data for the current Paginated.
Is the current page's fetch request still loading?
Did the current page load successfully but return no items?
Are there page's before the current one?
Are there page's after the current one?
Move to the next page.
TODO: re-implement as call to jumpTo?
Move to the previous page.
TODO: re-implement as call to jumpTo?
Move to a specific page.
Replace the current Extra Request Data, jumping to page 1 & performing new fetch requests. Does nothing if the Data is equal to existing Data.
Wrap an Http Response for a Page, to be handled in the update function.
Update the Paginated Model on Fetch Completion.
If the Page Number of the Returned Model is Different than the Given Model, We Were On a Page That Didn't Exist, So We Changed to the Last Page.
You Should Handle this Special Case in your Update Function, so that You can Modify the Page URL.
The
Paginatedtype is responsible for storing the fetched items, current page number, total count, and additional data to pass to the fetch command..