Paginator
Parses a backend response into a PaginatedCollection and syncs the result back into the store.
This is the half of the library that closes the loop: QueryBuilder
produces a URI, the consumer fetches it, and paginate() turns the body
into rows plus page metadata — recording the page and last page so that
hasNextPage(), lastPage() and totalPages() stop throwing
PaginationNotSyncedError.
It performs no I/O of its own. Fetch however you like and hand the body back.
Constructor
Section titled “Constructor”new Paginator(store: QubeeStore, responseStrategy: IResponseStrategy, options: ResponseOptions)| Parameter | Type | Description |
|---|---|---|
store |
QubeeStore |
The store to sync page metadata into |
responseStrategy |
IResponseStrategy |
Driver strategy that parses the response envelope |
options |
ResponseOptions |
Response key names for the active driver |
Methods
Section titled “Methods”paginate()
Section titled “paginate()”paginate(response: RawResponse, headers?: HeaderBag): PaginatedCollection<T>Parse a response body and sync its pagination state into the store.
lastPage is only synced when the backend actually reported a usable
value — a driver that cannot know the total (a bare cursor API, say)
leaves the store’s isLastPageKnown flag false rather than guessing.
| Parameter | Type | Description |
|---|---|---|
response |
RawResponse |
The raw response body, as returned by the backend |
headers |
HeaderBag |
Response headers, for drivers that paginate over them |
Returns — The parsed rows and page metadata
